From e206e871978634f8a5d55151d11e72fd3fa26f46 Mon Sep 17 00:00:00 2001 From: zhouchangcheng Date: Mon, 27 May 2024 15:15:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/HandleNotice.php | 4 ++-- app/Console/Kernel.php | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Console/Commands/HandleNotice.php b/app/Console/Commands/HandleNotice.php index aea025a..b37c541 100644 --- a/app/Console/Commands/HandleNotice.php +++ b/app/Console/Commands/HandleNotice.php @@ -44,7 +44,7 @@ public function __construct() public function handle(): int { $chunk = $this->argument('chunk'); - $this->info('开始消息队列'); + $this->info(date('Y-m-d H:i:s') . ' 开始消息队列'); $res = apiRequest::api('/Notic/getNotics', []); if (!$res['result'] || $res['errCode'] != '0000') { $this->error('request err: ' . $res['desc'] ?? ''); @@ -94,7 +94,7 @@ public function handle(): int } $count += count($queue); } - $this->info('添加了' . $count . '条记录'); + $this->info(date('Y-m-d H:i:s') . ' 添加了' . $count . '个任务'); return 0; } } diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index ca56ca2..f2ed99d 100755 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -2,6 +2,7 @@ namespace App\Console; +use App\Console\Commands\HandleNotice; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; @@ -12,7 +13,8 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule): void { - $schedule->command('handle:notice')->everySecond(); + $schedule->command(HandleNotice::class)->everyFiveSeconds()->withoutOverlapping(); + //->appendOutputTo('crontab.log'); } /** @@ -20,7 +22,7 @@ protected function schedule(Schedule $schedule): void */ protected function commands(): void { - $this->load(__DIR__.'/Commands'); + $this->load(__DIR__ . '/Commands'); require base_path('routes/console.php'); }