移除 Machine status forwarded 紀錄
修正問題 20250605
This commit is contained in:
parent
13b5e3e3e1
commit
e92848231d
@ -23,9 +23,8 @@ class CheckRoomOnlineStatus extends Command
|
||||
$rooms = Room::with('branch')->where('is_online',1)->get();
|
||||
|
||||
foreach ($rooms as $room) {
|
||||
// 找出最近的一筆 MachineStatus 資料(比對 hostname 和 branch_name)
|
||||
$branch = optional($room->branch);
|
||||
$latestStatus = MachineStatus::where('hostname', $room->type->value.$room->name)
|
||||
//->where('branch_name', optional($room->branch)->name)
|
||||
->latest('created_at')
|
||||
->first();
|
||||
|
||||
@ -34,12 +33,15 @@ class CheckRoomOnlineStatus extends Command
|
||||
$room->status = RoomStatus::Error;
|
||||
$room->save();
|
||||
|
||||
$response = (new MachineStatusForwarder($rooms->branch->external_ip, "/api/room/receiveSwitch", [
|
||||
"branch_name"=>$rooms->branch->name,
|
||||
"room_name"=>$rooms->type->value.$rooms->name,
|
||||
"command" =>"error",
|
||||
|
||||
]))->forward();
|
||||
$response = (new MachineStatusForwarder(
|
||||
$branch->external_ip ?? '',
|
||||
'/api/room/receiveSwitch',
|
||||
[
|
||||
'branch_name' => $branch->name,
|
||||
'room_name' => $room->type->value.$room->name,
|
||||
'command' => 'error',
|
||||
]
|
||||
))->forward();
|
||||
$this->info("Room [{$room->name}] marked as offline (no recent MachineStatus)");
|
||||
}
|
||||
}
|
||||
|
@ -39,12 +39,12 @@ class MachineStatusForwarder
|
||||
$client = new ApiClient($mainDomainUrl, $this->user->api_plain_token);
|
||||
$response = $client->post($this->endpoint, $this->validated);
|
||||
|
||||
Log::info('✅ Machine status forwarded', [
|
||||
/* Log::info('✅ Machine status forwarded', [
|
||||
'endpoint' => $this->endpoint,
|
||||
'request' => $this->validated,
|
||||
'status' => $response->status(),
|
||||
'body' => $response->json(),
|
||||
]);
|
||||
]); */
|
||||
} else {
|
||||
Log::warning("🔒 User with ID 2 not found or missing token");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user