where('created_at', '<', now()->subHour())->chunk(100, function ($hosts) { foreach ($hosts as $host) { // 忽略维护中的模块 if ($host->module->status !== 'up') { continue; } $response = $host->module->http()->get('hosts/' . $host->id); $status = $response->status(); if ($status === 200) { // 更新主机 $host->update($response->json()); } else if ($status === 404) { Log::warning($host->module->name . ' ' . $host->name . ' ' . $host->id . ' 不存在,删除。'); dispatch(new Module\HostJob($host, 'delete')); } } }); } }