更新
This commit is contained in:
@@ -31,6 +31,14 @@ use app\common\service\crontab\CrontabAlertService;
|
||||
*/
|
||||
class Crontab extends Command
|
||||
{
|
||||
protected const CRAWLER_MIGRATED_MESSAGE = 'crawler任务已迁移到Docker容器调度,请查看管理端爬虫任务日志';
|
||||
|
||||
protected const CRAWLER_MIGRATED_COMMANDS = [
|
||||
'crawler',
|
||||
'truth_social',
|
||||
'fifa_worldcup_news',
|
||||
];
|
||||
|
||||
protected const CRAWLER_DEFAULT_TIMEOUT = 600;
|
||||
|
||||
protected const CRAWLER_ACTION_TIMEOUTS = [
|
||||
@@ -96,8 +104,8 @@ class Crontab extends Command
|
||||
|
||||
public static function start($item)
|
||||
{
|
||||
if ($item['command'] === 'crawler') {
|
||||
self::startCrawler($item);
|
||||
if (in_array($item['command'], self::CRAWLER_MIGRATED_COMMANDS, true)) {
|
||||
self::skipMigratedCrawler($item);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -158,6 +166,14 @@ class Crontab extends Command
|
||||
}
|
||||
}
|
||||
|
||||
protected static function skipMigratedCrawler(array $item): void
|
||||
{
|
||||
CrontabModel::where('id', $item['id'])->update([
|
||||
'last_time' => time(),
|
||||
'error' => self::CRAWLER_MIGRATED_MESSAGE,
|
||||
]);
|
||||
}
|
||||
|
||||
protected static function startCrawler($item)
|
||||
{
|
||||
$crawlerDir = app()->getRootPath() . 'public/dongqiudi-crawler';
|
||||
|
||||
Reference in New Issue
Block a user