Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6
正在显示
4 个修改的文件
包含
78 行增加
和
3 行删除
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :TemplateLog.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2024/7/10 14:44 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Console\Commands\DeleteTemplate; | ||
| 11 | + | ||
| 12 | +use App\Models\Project\Project; | ||
| 13 | +use App\Services\ProjectServer; | ||
| 14 | +use Illuminate\Console\Command; | ||
| 15 | +use Illuminate\Support\Facades\DB; | ||
| 16 | + | ||
| 17 | +class TemplateLog extends Command | ||
| 18 | +{ | ||
| 19 | + /** | ||
| 20 | + * The name and signature of the console command. | ||
| 21 | + * | ||
| 22 | + * @var string | ||
| 23 | + */ | ||
| 24 | + protected $signature = 'delete_template_log'; | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * The console command description. | ||
| 28 | + * | ||
| 29 | + * @var string | ||
| 30 | + */ | ||
| 31 | + protected $description = '定时清理日志'; | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * Create a new command instance. | ||
| 35 | + * | ||
| 36 | + * @return void | ||
| 37 | + */ | ||
| 38 | + public function __construct() | ||
| 39 | + { | ||
| 40 | + parent::__construct(); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + public function handle(){ | ||
| 44 | + $projectModel = new Project(); | ||
| 45 | + $list = $projectModel->list(['delete_status'=>0]); | ||
| 46 | + foreach ($list as $v){ | ||
| 47 | + echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; | ||
| 48 | + ProjectServer::useProject($v['id']); | ||
| 49 | + DB::disconnect('custom_mysql'); | ||
| 50 | + } | ||
| 51 | + echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * @remark :定时清理可视化日志 | ||
| 56 | + * @name :deleteTemplate | ||
| 57 | + * @author :lyh | ||
| 58 | + * @method :post | ||
| 59 | + * @time :2024/7/10 14:48 | ||
| 60 | + */ | ||
| 61 | + public function deleteTemplate(){ | ||
| 62 | + | ||
| 63 | + } | ||
| 64 | +} |
| @@ -31,10 +31,14 @@ class SyncSubmitTask extends Command | @@ -31,10 +31,14 @@ class SyncSubmitTask extends Command | ||
| 31 | while (true) { | 31 | while (true) { |
| 32 | $task_id = Redis::rpop('sync_submit_task'); | 32 | $task_id = Redis::rpop('sync_submit_task'); |
| 33 | if(!$task_id){ | 33 | if(!$task_id){ |
| 34 | - sleep(3); | ||
| 35 | continue; | 34 | continue; |
| 36 | } | 35 | } |
| 36 | + | ||
| 37 | $this->output('任务' . $task_id . '开始'); | 37 | $this->output('任务' . $task_id . '开始'); |
| 38 | + | ||
| 39 | + $time = time(); | ||
| 40 | + DB::enableQueryLog(); //启用查询日志 | ||
| 41 | + | ||
| 38 | $task_info = SyncSubmitTaskModel::find($task_id); | 42 | $task_info = SyncSubmitTaskModel::find($task_id); |
| 39 | if (empty($task_info) || $task_info->status !=3) { | 43 | if (empty($task_info) || $task_info->status !=3) { |
| 40 | $this->output('任务不存在或者已执行'); | 44 | $this->output('任务不存在或者已执行'); |
| @@ -43,7 +47,6 @@ class SyncSubmitTask extends Command | @@ -43,7 +47,6 @@ class SyncSubmitTask extends Command | ||
| 43 | try { | 47 | try { |
| 44 | $project = Project::getProjectByDomain($task_info['data']['domain'] ?? ''); | 48 | $project = Project::getProjectByDomain($task_info['data']['domain'] ?? ''); |
| 45 | $task_info->project_id = $project->id; | 49 | $task_info->project_id = $project->id; |
| 46 | - | ||
| 47 | SyncSubmitTaskService::handler($task_info); | 50 | SyncSubmitTaskService::handler($task_info); |
| 48 | $task_info->status = 1; | 51 | $task_info->status = 1; |
| 49 | $task_info->save(); | 52 | $task_info->save(); |
| @@ -68,6 +71,12 @@ class SyncSubmitTask extends Command | @@ -68,6 +71,12 @@ class SyncSubmitTask extends Command | ||
| 68 | 71 | ||
| 69 | $this->output('任务失败:' . $e->getMessage()); | 72 | $this->output('任务失败:' . $e->getMessage()); |
| 70 | } | 73 | } |
| 74 | + | ||
| 75 | + $use_time = time() - $time; | ||
| 76 | + if($use_time > 1){ | ||
| 77 | + //数据库查询 | ||
| 78 | + $this->output('任务用时:' .$use_time . ' | ' . json_encode(DB::getQueryLog(),JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); | ||
| 79 | + } | ||
| 71 | } | 80 | } |
| 72 | } | 81 | } |
| 73 | 82 |
| @@ -177,6 +177,9 @@ class ProjectLogic extends BaseLogic | @@ -177,6 +177,9 @@ class ProjectLogic extends BaseLogic | ||
| 177 | * @time :2024/6/25 15:34 | 177 | * @time :2024/6/25 15:34 |
| 178 | */ | 178 | */ |
| 179 | public function setServers($servers_id,$project_id){ | 179 | public function setServers($servers_id,$project_id){ |
| 180 | + if(empty($servers_id)){ | ||
| 181 | + return $this->success(); | ||
| 182 | + } | ||
| 180 | //查看當前項目服務器是否有更改 | 183 | //查看當前項目服務器是否有更改 |
| 181 | $projectModel = new Project(); | 184 | $projectModel = new Project(); |
| 182 | $projectInfo = $projectModel->read(['id'=>$project_id],['serve_id']); | 185 | $projectInfo = $projectModel->read(['id'=>$project_id],['serve_id']); |
-
请 注册 或 登录 后发表评论