Browse Source

1.修正数据库高负载BUG(杜若)
2.优化queue.sh脚本(vft9nesd)

admin 7 năm trước cách đây
mục cha
commit
1788f82b79

+ 4 - 0
app/Console/Commands/AutoClearLog.php

@@ -10,6 +10,7 @@ use App\Http\Models\SsNodeTrafficHourly;
 use App\Http\Models\SsNodeTrafficDaily;
 use App\Http\Models\UserBanLog;
 use App\Http\Models\UserLoginLog;
+use App\Http\Models\UserSubscribeLog;
 use App\Http\Models\UserTrafficDaily;
 use App\Http\Models\UserTrafficLog;
 use App\Http\Models\UserTrafficHourly;
@@ -75,6 +76,9 @@ class AutoClearLog extends Command
 
         // 自动清除3个月以前用户登陆日志
         UserLoginLog::query()->where('created_at', '<=', date('Y-m-d H:i:s', strtotime("-3 month")))->delete();
+
+        // 自动清除1个月前的用户订阅记录
+        UserSubscribeLog::query()->where('request_time', '<=', date('Y-m-d H:i:s', strtotime("-1 month")))->delete();
     }
 
 }

+ 2 - 2
app/Http/Controllers/AuthController.php

@@ -77,7 +77,7 @@ class AuthController extends Controller
                 if (Auth::user()->status < 0) {
                     Session::flash('errorMsg', '账号已禁用');
 
-                    Auth::logout(); // 强制退出会话,因为Auth::attempt的时候会产生会话
+                    Auth::logout(); // 强制销毁会话,因为Auth::attempt的时候会产生会话
 
                     return Redirect::back()->withInput();
                 }
@@ -85,7 +85,7 @@ class AuthController extends Controller
                 if (Auth::user()->status == 0 && self::$systemConfig['is_active_register']) {
                     Session::flash('errorMsg', '账号未激活,请点击<a href="/activeUser?username=' . Auth::user()->username . '" target="_blank"><span style="color:#000">【激活账号】</span></a>');
 
-                    Auth::logout(); // 强制退出会话,因为Auth::attempt的时候会产生会话
+                    Auth::logout(); // 强制销毁会话,因为Auth::attempt的时候会产生会话
 
                     return Redirect::back()->withInput();
                 }

+ 8 - 1
queue.sh

@@ -1,2 +1,9 @@
 #!/bin/bash
-nohup php artisan queue:work database --queue=default --timeout=60 --sleep=5 --tries=3 >> ./storage/logs/queue.log 2>&1 &
+ps -ef | grep queue:work | grep -v grep
+if [ $? -ne 0 ]
+then
+    echo "start queue process successfully....."
+    nohup php artisan queue:work database --queue=default --timeout=60 --sleep=5 --tries=3 >> ./storage/logs/queue.log 2>&1 &
+else
+    echo "queue is running....."
+fi

+ 5 - 0
sql/update/20190213.sql

@@ -2,3 +2,8 @@
 ALTER TABLE `user`
 	CHANGE COLUMN `speed_limit_per_con` `speed_limit_per_con` BIGINT NOT NULL DEFAULT '10737418240' COMMENT '单连接限速,默认10M,为0表示不限速,单位Byte' AFTER `obfs_param`,
 	CHANGE COLUMN `speed_limit_per_user` `speed_limit_per_user` BIGINT NOT NULL DEFAULT '10737418240' COMMENT '单用户限速,默认10M,为0表示不限速,单位Byte' AFTER `speed_limit_per_con`;
+
+
+-- 优化数据库,防止暴库
+ALTER TABLE `user_subscribe_log`
+	ADD INDEX `sid` (`sid`);

+ 1 - 0
storage/framework/testing/.gitignore

@@ -1,2 +1,3 @@
 *
+*
 !.gitignore

BIN
storage/qqwry.dat