Quellcode durchsuchen

修改bug监控

kevin_zhangl vor 3 Jahren
Ursprung
Commit
52be5a920a

+ 21 - 0
console/controllers/ToolController.php

@@ -12,6 +12,7 @@ use common\helpers\Cache;
 use common\helpers\DataBak;
 use common\helpers\Date;
 use common\helpers\Form;
+use common\helpers\LoggerTool;
 use common\helpers\ocr\OcrApi;
 use common\helpers\Tool;
 use common\libs\api\sms\SmsApi;
@@ -167,4 +168,24 @@ class ToolController extends BaseController
         \Yii::$app->redis->del(Cache::USER_RELATION_PARENTS);
     }
 
+    /**
+     * 自动送钉钉提醒
+     */
+    public function actionAutoSendDingTalkTable() {
+        $curl = curl_init();
+        curl_setopt($curl, CURLOPT_URL, 'http://16.163.228.151:8026/v1/site/send-notice');
+        curl_setopt($curl, CURLOPT_TIMEOUT, 5000);
+        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
+        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
+        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
+        $res = curl_exec($curl);
+        if ($res) {
+            curl_close($curl);
+            LoggerTool::info($res);
+        } else {
+            $error = curl_errno($curl);
+            curl_close($curl);
+            LoggerTool::error($error);
+        }
+    }
 }

+ 1 - 1
frontendApi/modules/v1/controllers/SiteController.php

@@ -334,6 +334,6 @@ class SiteController extends BaseController
             'message' => 'autoSendDingTalk',
         ];
 
-        return static::notice(['data' => $data['heartbeat']]);
+        return static::notice(['data' => $data['bug监控正常运行,没有发现异常,奥利给!']]);
     }
 }

+ 7 - 0
vendor/yiisoft/yii2/web/ErrorHandler.php

@@ -9,6 +9,7 @@ namespace yii\web;
 
 use common\helpers\DingTalk;
 use common\helpers\LoggerTool;
+use common\helpers\Tool;
 use Yii;
 use yii\base\ErrorException;
 use yii\base\Exception;
@@ -175,6 +176,12 @@ class ErrorHandler extends \yii\base\ErrorHandler
                     $it['previous'] = $this->convertExceptionToArray($prev);
                 }
 
+                // 错误日志写入
+                $it['trace-id'] = Tool::generateId();
+                LoggerTool::error($it);
+
+                // 提醒只报出基本错误
+                unset($it['stack-trace']);
                 // 发送钉钉提醒
                 DingTalk::sendNotice($it);