From 3fc78bc760db86ebf7fc4c7c828afd1ed3a606b9 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 22 Sep 2023 20:39:56 +0200 Subject: [PATCH] wip: services --- app/Actions/Service/StartService.php | 2 +- app/Jobs/ContainerStatusJob.php | 6 +++--- app/Models/Service.php | 12 +++--------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/app/Actions/Service/StartService.php b/app/Actions/Service/StartService.php index e9c0ba546..113792f43 100644 --- a/app/Actions/Service/StartService.php +++ b/app/Actions/Service/StartService.php @@ -12,6 +12,7 @@ class StartService { $workdir = service_configuration_dir() . "/{$service->uuid}"; $commands[] = "echo '####### Starting service {$service->name} on {$service->server->name}.'"; + $commands[] = "echo '####### Pulling images.'"; $commands[] = "mkdir -p $workdir"; $commands[] = "cd $workdir"; @@ -22,7 +23,6 @@ class StartService foreach ($envs as $env) { $commands[] = "echo '{$env->key}={$env->value}' >> .env"; } - $commands[] = "echo '####### Pulling images.'"; $commands[] = "docker compose pull --quiet"; $commands[] = "echo '####### Starting containers.'"; $commands[] = "docker compose up -d >/dev/null 2>&1"; diff --git a/app/Jobs/ContainerStatusJob.php b/app/Jobs/ContainerStatusJob.php index 76060cdc6..1067d0028 100644 --- a/app/Jobs/ContainerStatusJob.php +++ b/app/Jobs/ContainerStatusJob.php @@ -157,7 +157,7 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted $foundServices[] = "$foundService->id-$serviceName"; $statusFromDb = $foundService->status; if ($statusFromDb !== $containerStatus) { - ray('Updating status: ' . $containerStatus); + // ray('Updating status: ' . $containerStatus); $foundService->update(['status' => $containerStatus]); } } @@ -169,14 +169,14 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted $apps = $service->applications()->get(); $dbs = $service->databases()->get(); foreach ($apps as $app) { - if (in_array("$service->id-$app->name", $foundServices)) { + if (in_array("$app->id-$app->name", $foundServices)) { continue; } else { $exitedServices->push($app); } } foreach ($dbs as $db) { - if (in_array("$service->id-$db->name", $foundServices)) { + if (in_array("$db->id-$db->name", $foundServices)) { continue; } else { $exitedServices->push($db); diff --git a/app/Models/Service.php b/app/Models/Service.php index 13add6a15..afc916359 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -117,15 +117,10 @@ class Service extends BaseModel 'service_id' => $this->id ]); } else { - if (Str::of($serviceVariables)->contains('SERVICE_FQDN') || Str::of($serviceVariables)->contains('SERVICE_URL')) { - $defaultUsableFqdn = "http://$serviceName-{$this->uuid}.{$this->server->ip}.sslip.io"; - if (isDev()) { - $defaultUsableFqdn = "http://$serviceName-{$this->uuid}.127.0.0.1.sslip.io"; - } - } else { - $defaultUsableFqdn = null; + $defaultUsableFqdn = "http://$serviceName-{$this->uuid}.{$this->server->ip}.sslip.io"; + if (isDev()) { + $defaultUsableFqdn = "http://$serviceName-{$this->uuid}.127.0.0.1.sslip.io"; } - $savedService = ServiceApplication::create([ 'name' => $serviceName, 'fqdn' => $defaultUsableFqdn, @@ -155,7 +150,6 @@ class Service extends BaseModel if ($fqdns) { $fqdns = collect(Str::of($fqdns)->explode(',')); } - ray($fqdns); // Collect ports $servicePorts = collect(data_get($service, 'ports', [])); $ports->put($serviceName, $servicePorts);