更新模块
This commit is contained in:
parent
83613ac5d6
commit
08bedaa67b
@ -32,11 +32,15 @@ public function __construct()
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
// now 添加1.5小时
|
||||
|
||||
//
|
||||
// 删除所有模块中不存在的主机
|
||||
Host::with('module')->where('created_at', '<', now()->subHour())->chunk(100, function ($hosts) {
|
||||
foreach ($hosts as $host) {
|
||||
|
||||
// 忽略维护中的模块
|
||||
if ($host->module->status !== 'up') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$http = Http::module($host->module->api_token, $host->module->url);
|
||||
$response = $http->get('hosts/' . $host->id);
|
||||
|
||||
|
@ -58,7 +58,6 @@ public function handle()
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if ($response->successful()) {
|
||||
$json = $response->json();
|
||||
|
||||
@ -82,6 +81,18 @@ public function handle()
|
||||
// $module->update([
|
||||
// 'data' => $response->json()
|
||||
// ]);
|
||||
} else {
|
||||
|
||||
// if module return maintenance, then set module status to maintenance
|
||||
if ($response->status() == 503) {
|
||||
$module->update([
|
||||
'status' => 'maintenance'
|
||||
]);
|
||||
} else {
|
||||
$module->update([
|
||||
'status' => 'down'
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user