作者 刘锟

update

... ... @@ -16,6 +16,7 @@ use App\Models\Template\BCustomTemplate;
use App\Services\CosService;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
... ... @@ -54,10 +55,14 @@ class HtmlCollect extends Command
protected function start_collect()
{
$task_id = $this->get_task();
if (!$task_id) {
if ($task_id === false) {
//所有项目采集完成
sleep(60);
return true;
} elseif ($task_id === 0) {
//队列任务已处理完,有进程正在查询数据库,等待2秒后执行
sleep(2);
return true;
}
$task_arr = explode('_', $task_id);
... ... @@ -142,6 +147,11 @@ class HtmlCollect extends Command
return $task_id;
}
if (!Cache::add('html_collect_select_mysql', true, 10)) {
// 如果存在数据锁,则表示有其他进程正在查询数据库,直接返回
return 0;
}
$update_log_list = UpdateLog::where('status', UpdateLog::STATUS_COM)->where('collect_status', UpdateLog::COLLECT_STATUS_UN)->orderBy('updated_at', 'asc')->limit(20)->get();
if ($update_log_list->count() == 0) {
return false;
... ...