Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

Refactor restart tracking and add missing model casts

Andras Bacsaid04d0ab49979
diff --git a/app/Actions/Docker/GetContainersStatus.php b/app/Actions/Docker/GetContainersStatus.php
index df0d8cf14c..3631cca248 100644
--- a/app/Actions/Docker/GetContainersStatus.php
+++ b/app/Actions/Docker/GetContainersStatus.php
@@ -206,28 +206,19 @@ class GetContainersStatus
if ($statusFromDb !== $containerStatus) {
$updateData = ['status' => $containerStatus];
-
- // Update restart tracking if restart count increased
- if ($restartCount > $previousRestartCount) {
- $updateData['restart_count'] = $restartCount;
- $updateData['last_restart_at'] = now();
- $updateData['last_restart_type'] = 'crash';
- }
-
- $database->update($updateData);
} else {
$updateData = ['last_online_at' => now()];
+ }
- // Update restart tracking even if status unchanged
- if ($restartCount > $previousRestartCount) {
- $updateData['restart_count'] = $restartCount;
- $updateData['last_restart_at'] = now();
- $updateData['last_restart_type'] = 'crash';
- }
-
- $database->update($updateData);
+ // Update restart tracking if restart count increased
+ if ($restartCount > $previousRestartCount) {
+ $updateData['restart_count'] = $restartCount;
+ $updateData['last_restart_at'] = now();
+ $updateData['last_restart_type'] = 'crash';
}
+ $database->update($updateData);
+
if ($isPublic) {
$foundTcpProxy = $this->containers->filter(function ($value, $key) use ($uuid) {
if ($this->server->isSwarm()) {
diff --git a/app/Models/StandaloneClickhouse.php b/app/Models/StandaloneClickhouse.php
index 63485c6123..a76d55abbf 100644
--- a/app/Models/StandaloneClickhouse.php
+++ b/app/Models/StandaloneClickhouse.php
@@ -20,6 +20,7 @@ class StandaloneClickhouse extends BaseModel
'clickhouse_password' => 'encrypted',
'restart_count' => 'integer',
'last_restart_at' => 'datetime',
+ 'last_restart_type' => 'string',
];
protected static function booted()
diff --git a/app/Models/StandaloneDragonfly.php b/app/Models/StandaloneDragonfly.php
index 09f16752db..f5337b1d51 100644
--- a/app/Models/StandaloneDragonfly.php
+++ b/app/Models/StandaloneDragonfly.php
@@ -20,6 +20,7 @@ class StandaloneDragonfly extends BaseModel
'dragonfly_password' => 'encrypted',
'restart_count' => 'integer',
'last_restart_at' => 'datetime',
+ 'last_restart_type' => 'string',
];
protected static function booted()
diff --git a/app/Models/StandaloneKeydb.php b/app/Models/StandaloneKeydb.php
index c420bde157..ab24cae2c9 100644
--- a/app/Models/StandaloneKeydb.php
+++ b/app/Models/StandaloneKeydb.php
@@ -20,6 +20,7 @@ class StandaloneKeydb extends BaseModel
'keydb_password' => 'encrypted',
'restart_count' => 'integer',
'last_restart_at' => 'datetime',
+ 'last_restart_type' => 'string',
];
protected static function booted()
diff --git a/app/Models/StandaloneMariadb.php b/app/Models/StandaloneMariadb.php
index 52ae136bb3..e48cfc1e60 100644
--- a/app/Models/StandaloneMariadb.php
+++ b/app/Models/StandaloneMariadb.php
@@ -21,6 +21,7 @@ class StandaloneMariadb extends BaseModel
'mariadb_password' => 'encrypted',
'restart_count' => 'integer',
'last_restart_at' => 'datetime',
+ 'last_restart_type' => 'string',
];
protected static function booted()
diff --git a/app/Models/StandaloneMongodb.php b/app/Models/StandaloneMongodb.php
index f17c72dbc3..9e271b19a3 100644
--- a/app/Models/StandaloneMongodb.php
+++ b/app/Models/StandaloneMongodb.php
@@ -19,6 +19,7 @@ class StandaloneMongodb extends BaseModel
protected $casts = [
'restart_count' => 'integer',
'last_restart_at' => 'datetime',
+ 'last_restart_type' => 'string',
];
protected static function booted()
diff --git a/app/Models/StandaloneMysql.php b/app/Models/StandaloneMysql.php
index f4e1920474..377765697e 100644
--- a/app/Models/StandaloneMysql.php
+++ b/app/Models/StandaloneMysql.php
@@ -21,6 +21,7 @@ class StandaloneMysql extends BaseModel
'mysql_root_password' => 'encrypted',
'restart_count' => 'integer',
'last_restart_at' => 'datetime',
+ 'last_restart_type' => 'string',
];
protected static function booted()
diff --git a/app/Models/StandalonePostgresql.php b/app/Models/StandalonePostgresql.php
index 9e6c968aa2..d9993426a7 100644
--- a/app/Models/StandalonePostgresql.php
+++ b/app/Models/StandalonePostgresql.php
@@ -21,6 +21,7 @@ class StandalonePostgresql extends BaseModel
'postgres_password' => 'encrypted',
'restart_count' => 'integer',
'last_restart_at' => 'datetime',
+ 'last_restart_type' => 'string',
];
protected static function booted()
diff --git a/app/Models/StandaloneRedis.php b/app/Models/StandaloneRedis.php
index 05f8ae6c65..684bcaeb7b 100644
--- a/app/Models/StandaloneRedis.php
+++ b/app/Models/StandaloneRedis.php
@@ -19,6 +19,7 @@ class StandaloneRedis extends BaseModel
protected $casts = [
'restart_count' => 'integer',
'last_restart_at' => 'datetime',
+ 'last_restart_type' => 'string',
];
protected static function booted()