This commit is contained in:
zhouchangcheng 2024-05-27 15:15:51 +08:00
parent e35c59b4f8
commit e206e87197
2 changed files with 6 additions and 4 deletions

View File

@ -44,7 +44,7 @@ public function __construct()
public function handle(): int public function handle(): int
{ {
$chunk = $this->argument('chunk'); $chunk = $this->argument('chunk');
$this->info('开始消息队列'); $this->info(date('Y-m-d H:i:s') . ' 开始消息队列');
$res = apiRequest::api('/Notic/getNotics', []); $res = apiRequest::api('/Notic/getNotics', []);
if (!$res['result'] || $res['errCode'] != '0000') { if (!$res['result'] || $res['errCode'] != '0000') {
$this->error('request err: ' . $res['desc'] ?? ''); $this->error('request err: ' . $res['desc'] ?? '');
@ -94,7 +94,7 @@ public function handle(): int
} }
$count += count($queue); $count += count($queue);
} }
$this->info('添加了' . $count . '条记录'); $this->info(date('Y-m-d H:i:s') . ' 添加了' . $count . '个任务');
return 0; return 0;
} }
} }

View File

@ -2,6 +2,7 @@
namespace App\Console; namespace App\Console;
use App\Console\Commands\HandleNotice;
use Illuminate\Console\Scheduling\Schedule; use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
@ -12,7 +13,8 @@ class Kernel extends ConsoleKernel
*/ */
protected function schedule(Schedule $schedule): void protected function schedule(Schedule $schedule): void
{ {
$schedule->command('handle:notice')->everySecond(); $schedule->command(HandleNotice::class)->everyFiveSeconds()->withoutOverlapping();
//->appendOutputTo('crontab.log');
} }
/** /**