fix(push-server): track last_online_at and reset database restart state
- Update last_online_at timestamp when resource status is confirmed active - Reset restart_count, last_restart_at, and last_restart_type when marking database as exited - Remove unused updateServiceSubStatus() method
This commit is contained in:
parent
0a1782175a
commit
458f048c4e
1 changed files with 16 additions and 27 deletions
|
|
@ -307,6 +307,8 @@ private function aggregateMultiContainerStatuses()
|
||||||
if ($aggregatedStatus && $application->status !== $aggregatedStatus) {
|
if ($aggregatedStatus && $application->status !== $aggregatedStatus) {
|
||||||
$application->status = $aggregatedStatus;
|
$application->status = $aggregatedStatus;
|
||||||
$application->save();
|
$application->save();
|
||||||
|
} elseif ($aggregatedStatus) {
|
||||||
|
$application->update(['last_online_at' => now()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -321,6 +323,8 @@ private function aggregateMultiContainerStatuses()
|
||||||
if ($aggregatedStatus && $application->status !== $aggregatedStatus) {
|
if ($aggregatedStatus && $application->status !== $aggregatedStatus) {
|
||||||
$application->status = $aggregatedStatus;
|
$application->status = $aggregatedStatus;
|
||||||
$application->save();
|
$application->save();
|
||||||
|
} elseif ($aggregatedStatus) {
|
||||||
|
$application->update(['last_online_at' => now()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -371,6 +375,8 @@ private function aggregateServiceContainerStatuses()
|
||||||
if ($aggregatedStatus && $subResource->status !== $aggregatedStatus) {
|
if ($aggregatedStatus && $subResource->status !== $aggregatedStatus) {
|
||||||
$subResource->status = $aggregatedStatus;
|
$subResource->status = $aggregatedStatus;
|
||||||
$subResource->save();
|
$subResource->save();
|
||||||
|
} elseif ($aggregatedStatus) {
|
||||||
|
$subResource->update(['last_online_at' => now()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -386,6 +392,8 @@ private function aggregateServiceContainerStatuses()
|
||||||
if ($aggregatedStatus && $subResource->status !== $aggregatedStatus) {
|
if ($aggregatedStatus && $subResource->status !== $aggregatedStatus) {
|
||||||
$subResource->status = $aggregatedStatus;
|
$subResource->status = $aggregatedStatus;
|
||||||
$subResource->save();
|
$subResource->save();
|
||||||
|
} elseif ($aggregatedStatus) {
|
||||||
|
$subResource->update(['last_online_at' => now()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -415,6 +423,8 @@ private function updateApplicationPreviewStatus(string $applicationId, string $p
|
||||||
if ($application->status !== $containerStatus) {
|
if ($application->status !== $containerStatus) {
|
||||||
$application->status = $containerStatus;
|
$application->status = $containerStatus;
|
||||||
$application->save();
|
$application->save();
|
||||||
|
} else {
|
||||||
|
$application->update(['last_online_at' => now()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -549,8 +559,12 @@ private function updateNotFoundDatabaseStatus()
|
||||||
$database = $this->databases->where('uuid', $databaseUuid)->first();
|
$database = $this->databases->where('uuid', $databaseUuid)->first();
|
||||||
if ($database) {
|
if ($database) {
|
||||||
if (! str($database->status)->startsWith('exited')) {
|
if (! str($database->status)->startsWith('exited')) {
|
||||||
$database->status = 'exited';
|
$database->update([
|
||||||
$database->save();
|
'status' => 'exited',
|
||||||
|
'restart_count' => 0,
|
||||||
|
'last_restart_at' => null,
|
||||||
|
'last_restart_type' => null,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
if ($database->is_public) {
|
if ($database->is_public) {
|
||||||
StopDatabaseProxy::dispatch($database);
|
StopDatabaseProxy::dispatch($database);
|
||||||
|
|
@ -559,31 +573,6 @@ private function updateNotFoundDatabaseStatus()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private function updateServiceSubStatus(string $serviceId, string $subType, string $subId, string $containerStatus)
|
|
||||||
{
|
|
||||||
$service = $this->services->where('id', $serviceId)->first();
|
|
||||||
if (! $service) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($subType === 'application') {
|
|
||||||
$application = $service->applications->where('id', $subId)->first();
|
|
||||||
if ($application) {
|
|
||||||
if ($application->status !== $containerStatus) {
|
|
||||||
$application->status = $containerStatus;
|
|
||||||
$application->save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} elseif ($subType === 'database') {
|
|
||||||
$database = $service->databases->where('id', $subId)->first();
|
|
||||||
if ($database) {
|
|
||||||
if ($database->status !== $containerStatus) {
|
|
||||||
$database->status = $containerStatus;
|
|
||||||
$database->save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function updateNotFoundServiceStatus()
|
private function updateNotFoundServiceStatus()
|
||||||
{
|
{
|
||||||
$notFoundServiceApplicationIds = $this->allServiceApplicationIds->diff($this->foundServiceApplicationIds);
|
$notFoundServiceApplicationIds = $this->allServiceApplicationIds->diff($this->foundServiceApplicationIds);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue