增加 扫描出错的主机
This commit is contained in:
parent
612758adce
commit
f560f03e77
@ -4,7 +4,7 @@
|
||||
|
||||
use App\Jobs\Host\DeleteHostJob;
|
||||
use App\Jobs\Host\DispatchHostCostQueueJob;
|
||||
use App\Jobs\Host\ScanAllHostsJob;
|
||||
use App\Jobs\Host\ScanErrorHostsJob;
|
||||
use App\Jobs\Module\DispatchFetchModuleJob;
|
||||
use App\Jobs\Module\SendModuleEarningsJob;
|
||||
use App\Jobs\Subscription\DeleteDraftJob;
|
||||
@ -49,6 +49,9 @@ protected function schedule(Schedule $schedule): void
|
||||
// 检查主机是否存在于模块
|
||||
// $schedule->job(new ScanAllHostsJob())->everyThirtyMinutes()->withoutOverlapping()->onOneServer()->name('检查主机是否存在于模块');
|
||||
|
||||
// 扫描出错的主机
|
||||
$schedule->job(new ScanErrorHostsJob())->everyThirtyMinutes()->withoutOverlapping()->onOneServer()->name('扫描出错的主机');
|
||||
|
||||
// 检查未充值的订单,并充值
|
||||
$schedule->job(new CheckAndChargeBalanceJob())->everyFiveMinutes()->onOneServer()->withoutOverlapping()->name('检查未充值的订单,并充值');
|
||||
|
||||
|
33
app/Jobs/Host/ScanErrorHostsJob.php
Normal file
33
app/Jobs/Host/ScanErrorHostsJob.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Host;
|
||||
|
||||
use App\Models\Host;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class ScanErrorHostsJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
// 扫描出错的主机
|
||||
(new Host)->whereIn('status', ['error', 'pending', 'unavailable'])->with('module')->chunk(100, function ($hosts) {
|
||||
foreach ($hosts as $host) {
|
||||
// 忽略维护中的模块
|
||||
if ($host->module->status !== 'up') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$host->updateOrDelete();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user