作者 Your Name
<?php
/**
* @remark :
* @name :TemplateLog.php
* @author :lyh
* @method :post
* @time :2024/7/10 14:44
*/
namespace App\Console\Commands\DeleteTemplate;
use App\Models\Project\Project;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class TemplateLog extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'delete_template_log';
/**
* The console command description.
*
* @var string
*/
protected $description = '定时清理日志';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['delete_status'=>0]);
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
/**
* @remark :定时清理可视化日志
* @name :deleteTemplate
* @author :lyh
* @method :post
* @time :2024/7/10 14:48
*/
public function deleteTemplate(){
}
}
... ...
... ... @@ -31,10 +31,14 @@ class SyncSubmitTask extends Command
while (true) {
$task_id = Redis::rpop('sync_submit_task');
if(!$task_id){
sleep(3);
continue;
}
$this->output('任务' . $task_id . '开始');
$time = time();
DB::enableQueryLog(); //启用查询日志
$task_info = SyncSubmitTaskModel::find($task_id);
if (empty($task_info) || $task_info->status !=3) {
$this->output('任务不存在或者已执行');
... ... @@ -43,7 +47,6 @@ class SyncSubmitTask extends Command
try {
$project = Project::getProjectByDomain($task_info['data']['domain'] ?? '');
$task_info->project_id = $project->id;
SyncSubmitTaskService::handler($task_info);
$task_info->status = 1;
$task_info->save();
... ... @@ -68,6 +71,12 @@ class SyncSubmitTask extends Command
$this->output('任务失败:' . $e->getMessage());
}
$use_time = time() - $time;
if($use_time > 1){
//数据库查询
$this->output('任务用时:' .$use_time . ' | ' . json_encode(DB::getQueryLog(),JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
}
}
}
... ...
... ... @@ -44,7 +44,6 @@ class SyncSubmitTaskDistribution extends Command
}
}
}
sleep(3);
}
}
... ...
... ... @@ -177,6 +177,9 @@ class ProjectLogic extends BaseLogic
* @time :2024/6/25 15:34
*/
public function setServers($servers_id,$project_id){
if(empty($servers_id)){
return $this->success();
}
//查看當前項目服務器是否有更改
$projectModel = new Project();
$projectInfo = $projectModel->read(['id'=>$project_id],['serve_id']);
... ...