diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index a820811..f62d4ff 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -2,7 +2,7 @@ namespace App\Console; -use App\Jobs\Host\DeleteHostJob; +use App\Jobs\Host\DeleteSuspendedHostJob; use App\Jobs\Host\DispatchHostCostQueueJob; use App\Jobs\Host\ScanAllHostsJob; use App\Jobs\Module\FetchModuleJob; @@ -45,7 +45,7 @@ protected function schedule(Schedule $schedule): void $schedule->job(new ClearTasksJob())->weekly(); // 删除暂停或部署时间超过 3 天以上的主机 - $schedule->job(new DeleteHostJob())->hourly(); + $schedule->job(new DeleteSuspendedHostJob())->hourly(); // 检查主机是否存在于模块 $schedule->job(new ScanAllHostsJob())->everyThirtyMinutes()->withoutOverlapping()->onOneServer(); diff --git a/app/Jobs/Host/DeleteHostJob.php b/app/Jobs/Host/DeleteSuspendedHostJob.php similarity index 95% rename from app/Jobs/Host/DeleteHostJob.php rename to app/Jobs/Host/DeleteSuspendedHostJob.php index 9c38742..234946f 100644 --- a/app/Jobs/Host/DeleteHostJob.php +++ b/app/Jobs/Host/DeleteSuspendedHostJob.php @@ -10,7 +10,7 @@ // use Illuminate\Contracts\Queue\ShouldBeUnique; -class DeleteHostJob implements ShouldQueue +class DeleteSuspendedHostJob implements ShouldQueue { use InteractsWithQueue, Queueable, SerializesModels; diff --git a/app/Jobs/Host/UpdateOrDeleteHostJob.php b/app/Jobs/Host/UpdateOrSuspendedHostJob.php similarity index 91% rename from app/Jobs/Host/UpdateOrDeleteHostJob.php rename to app/Jobs/Host/UpdateOrSuspendedHostJob.php index 6bb0a67..3f8356c 100644 --- a/app/Jobs/Host/UpdateOrDeleteHostJob.php +++ b/app/Jobs/Host/UpdateOrSuspendedHostJob.php @@ -11,7 +11,7 @@ use Illuminate\Support\Arr; use Illuminate\Support\Facades\Log; -class UpdateOrDeleteHostJob implements ShouldQueue +class UpdateOrSuspendedHostJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; @@ -41,7 +41,7 @@ public function handle(): void if ($response['status'] === 200) { $host->update(Arr::except($response['json'], ['id', 'user_id', 'module_id', 'created_at', 'updated_at'])); } else if ($response['status'] === 404) { - Log::warning($host->module->name . ' ' . $host->name . ' ' . $host->id . ' 不存在,删除。'); + Log::warning($host->module->name . ' ' . $host->name . ' ' . $host->id . ' 不存在,标记为暂停。'); dispatch(new HostJob($host, 'delete')); } } diff --git a/app/Models/Host.php b/app/Models/Host.php index 7587983..10c6dd1 100644 --- a/app/Models/Host.php +++ b/app/Models/Host.php @@ -4,7 +4,7 @@ use App\Events\Users; use App\Jobs\Host\HostJob; -use App\Jobs\Host\UpdateOrDeleteHostJob; +use App\Jobs\Host\UpdateOrSuspendedHostJob; use App\Notifications\WebNotification; use GeneaLabs\LaravelModelCaching\Traits\Cachable; use Illuminate\Database\Eloquent\Collection; @@ -307,7 +307,7 @@ public function addLog(string $amount = "0"): bool public function updateOrDelete(): bool { - dispatch(new UpdateOrDeleteHostJob($this)); + dispatch(new UpdateOrSuspendedHostJob($this)); return true; }