diff --git a/app/Models/Server.php b/app/Models/Server.php index f5cf84604..828500c40 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -17,6 +17,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Carbon; use Illuminate\Support\Collection; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Stringable; use OpenApi\Attributes as OA; @@ -24,6 +25,7 @@ use Spatie\SchemalessAttributes\Casts\SchemalessAttributes; use Spatie\SchemalessAttributes\SchemalessAttributesTrait; use Spatie\Url\Url; use Symfony\Component\Yaml\Yaml; +use Visus\Cuid2\Cuid2; #[OA\Schema( description: 'Server model', @@ -101,11 +103,13 @@ class Server extends BaseModel 'server_id' => $server->id, ]); } else { - StandaloneDocker::create([ + $standaloneDocker = new StandaloneDocker([ 'name' => 'coolify', + 'uuid' => (string) new Cuid2, 'network' => 'coolify', 'server_id' => $server->id, ]); + $standaloneDocker->saveQuietly(); } } if (! isset($server->proxy->redirect_enabled)) { @@ -705,22 +709,6 @@ $schema://$host { ]; } - public function getContainersWithSentinel(): Collection - { - $sentinel_found = instant_remote_process(['docker inspect coolify-sentinel'], $this, false); - $sentinel_found = json_decode($sentinel_found, true); - $status = data_get($sentinel_found, '0.State.Status', 'exited'); - if ($status === 'running') { - $containers = instant_remote_process(['docker exec coolify-sentinel sh -c "curl http://127.0.0.1:8888/api/containers"'], $this, false); - if (is_null($containers)) { - return collect([]); - } - $containers = data_get(json_decode($containers, true), 'containers', []); - - return collect($containers); - } - } - public function loadAllContainers(): Collection { if ($this->isFunctional()) { @@ -1036,7 +1024,7 @@ $schema://$host { $unreachableNotificationSent = (bool) $this->unreachable_notification_sent; $isReachable = (bool) $this->settings->is_reachable; - \Log::debug('Server reachability check', [ + Log::debug('Server reachability check', [ 'server_id' => $this->id, 'is_reachable' => $isReachable, 'notification_sent' => $unreachableNotificationSent, @@ -1048,7 +1036,7 @@ $schema://$host { $this->save(); if ($unreachableNotificationSent === true) { - \Log::debug('Server is now reachable, sending notification', [ + Log::debug('Server is now reachable, sending notification', [ 'server_id' => $this->id, ]); $this->sendReachableNotification(); @@ -1058,7 +1046,7 @@ $schema://$host { } $this->increment('unreachable_count'); - \Log::debug('Incremented unreachable count', [ + Log::debug('Incremented unreachable count', [ 'server_id' => $this->id, 'new_count' => $this->unreachable_count, ]); @@ -1066,7 +1054,7 @@ $schema://$host { if ($this->unreachable_count === 1) { $this->settings->is_reachable = true; $this->settings->save(); - \Log::debug('First unreachable attempt, marking as reachable', [ + Log::debug('First unreachable attempt, marking as reachable', [ 'server_id' => $this->id, ]); @@ -1077,7 +1065,7 @@ $schema://$host { $failedChecks = 0; for ($i = 0; $i < 3; $i++) { $status = $this->serverStatus(); - \Log::debug('Additional reachability check', [ + Log::debug('Additional reachability check', [ 'server_id' => $this->id, 'attempt' => $i + 1, 'status' => $status, @@ -1089,7 +1077,7 @@ $schema://$host { } if ($failedChecks === 3 && ! $unreachableNotificationSent) { - \Log::debug('Server confirmed unreachable after 3 attempts, sending notification', [ + Log::debug('Server confirmed unreachable after 3 attempts, sending notification', [ 'server_id' => $this->id, ]); $this->sendUnreachableNotification();