作者 lyh

gx

<?php
/**
* @remark :
* @name :UpdateProgress.php
* @author :lyh
* @method :post
* @time :2023/11/1 9:22
*/
namespace App\Console\Commands;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
use App\Models\Com\UpdateProgress as UpdateProgressModel;
class UpdateProgress extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'update_progress';
/**
* The console command description.
*
* @var string
*/
protected $description = '守护进程--更新界面';
/**
* @name :(定时执行)handle
* @author :lyh
* @method :post
* @time :2023/5/12 14:48
*/
public function handle()
{
while (true){
$project_id = Redis::rpop('updateSeoTdk');
if(!$project_id){
sleep(2);
continue;
}
echo date('Y-m-d H:i:s') . ' start: ' . $project_id . PHP_EOL;
try {
ProjectServer::useProject($project_id);
DB::disconnect('custom_mysql');
}catch (\Exception $e){
echo date('Y-m-d H:i:s') . ' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL;
}
echo date('Y-m-d H:i:s') . ' end: ' . $project_id . PHP_EOL;
}
}
/**
* @remark :查看是否有为更新的记录
* @name :updateProgress
* @author :lyh
* @method :post
* @time :2023/11/1 10:47
*/
public function getUpdateProgress(){
$list = DB::connection('custom_mysql')->table('gl_update_progress')->whereRaw('total_num > current_num')->get();
if(!empty($list)){
$list = $list->toArray();
}
}
}
... ...
... ... @@ -3,10 +3,7 @@
namespace App\Console\Commands;
use App\Helper\Common;
use App\Helper\Translate;
use App\Models\Ai\AiCommand as AiCommandModel;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Project;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
... ...
... ... @@ -19,6 +19,7 @@ use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Models\WebSetting\WebSettingCountry;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redis;
/**
* @remark :通知C端
... ... @@ -139,7 +140,9 @@ class CNoticeController extends BaseController
'created_at'=>date('Y-m-d H;i:s')
];
$updateProgressModel = new UpdateProgress();
return $updateProgressModel->insert($data);
$updateProgressModel->insert($data);
Redis::lpush('updateProgress', $this->param['project_id']);
return true;
}
/**
... ...