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.

fix: proxy start job

Andras Bacsaif75a324030f3
diff --git a/app/Actions/Proxy/SaveConfigurationSync.php b/app/Actions/Proxy/SaveConfigurationSync.php
index c176075168..b35b4375bd 100644
--- a/app/Actions/Proxy/SaveConfigurationSync.php
+++ b/app/Actions/Proxy/SaveConfigurationSync.php
@@ -9,15 +9,20 @@ class SaveConfigurationSync
{
public function __invoke(Server $server, string $configuration)
{
- $proxy_path = get_proxy_path();
- $docker_compose_yml_base64 = base64_encode($configuration);
+ try {
+ $proxy_path = get_proxy_path();
+ $docker_compose_yml_base64 = base64_encode($configuration);
- $server->proxy->last_saved_settings = Str::of($docker_compose_yml_base64)->pipe('md5')->value;
- $server->save();
+ $server->proxy->last_saved_settings = Str::of($docker_compose_yml_base64)->pipe('md5')->value;
+ $server->save();
+
+ instant_remote_process([
+ "mkdir -p $proxy_path",
+ "echo '$docker_compose_yml_base64' | base64 -d > $proxy_path/docker-compose.yml",
+ ], $server);
+ } catch (\Throwable $th) {
+ ray($th);
+ }
- instant_remote_process([
- "mkdir -p $proxy_path",
- "echo '$docker_compose_yml_base64' | base64 -d > $proxy_path/docker-compose.yml",
- ], $server);
}
}
diff --git a/app/Actions/Proxy/StartProxy.php b/app/Actions/Proxy/StartProxy.php
index b9d9ab02b0..d541921be3 100644
--- a/app/Actions/Proxy/StartProxy.php
+++ b/app/Actions/Proxy/StartProxy.php
@@ -12,12 +12,6 @@ class StartProxy
{
public function __invoke(Server $server): Activity
{
- // TODO: check for other proxies
- if (is_null(data_get($server, 'proxy.type'))) {
- $server->proxy->type = ProxyTypes::TRAEFIK_V2->value;
- $server->proxy->status = ProxyStatus::EXITED->value;
- $server->save();
- }
$proxy_path = get_proxy_path();
$networks = collect($server->standaloneDockers)->map(function ($docker) {
return $docker['network'];
diff --git a/app/Jobs/DockerCleanupJob.php b/app/Jobs/DockerCleanupJob.php
index 071846fe6e..6ac00bc4b1 100644
--- a/app/Jobs/DockerCleanupJob.php
+++ b/app/Jobs/DockerCleanupJob.php
@@ -34,7 +34,13 @@ class DockerCleanupJob implements ShouldQueue
if (isDev()) {
$this->dockerRootFilesystem = "/";
} else {
- $this->dockerRootFilesystem = instant_remote_process(["stat --printf=%m $(docker info --format '{{json .DockerRootDir}}'' |sed 's/\"//g')"], $server, false);
+ $this->dockerRootFilesystem = instant_remote_process(
+ [
+ "stat --printf=%m $(docker info --format '{{json .DockerRootDir}}'' |sed 's/\"//g')"
+ ],
+ $server,
+ false
+ );
}
if (!$this->dockerRootFilesystem) {
continue;
@@ -47,9 +53,9 @@ class DockerCleanupJob implements ShouldQueue
instant_remote_process(['docker builder prune -af'], $server);
$usageAfter = $this->getFilesystemUsage($server);
if ($usageAfter < $this->usageBefore) {
- ray('Saved ' . ( $this->usageBefore - $usageAfter) . '% disk space on ' . $server->name)->color('orange');
- send_internal_notification('DockerCleanupJob done: Saved ' . ( $this->usageBefore - $usageAfter) . '% disk space on ' . $server->name);
- }else {
+ ray('Saved ' . ($this->usageBefore - $usageAfter) . '% disk space on ' . $server->name)->color('orange');
+ send_internal_notification('DockerCleanupJob done: Saved ' . ($this->usageBefore - $usageAfter) . '% disk space on ' . $server->name);
+ } else {
ray('DockerCleanupJob failed to save disk space on ' . $server->name)->color('orange');
}
} else {
diff --git a/app/Jobs/ProxyCheckJob.php b/app/Jobs/ProxyCheckJob.php
index 9d55590532..720dd2ea1a 100755
--- a/app/Jobs/ProxyCheckJob.php
+++ b/app/Jobs/ProxyCheckJob.php
@@ -33,8 +33,9 @@ class ProxyCheckJob implements ShouldQueue
if ($status === 'running') {
continue;
}
- // $server->team->notify(new ProxyStoppedNotification($server));
- resolve(StartProxy::class)($server);
+ if (data_get($server, 'proxy.type')) {
+ resolve(StartProxy::class)($server);
+ }
}
} catch (\Throwable $th) {
ray($th->getMessage());
diff --git a/app/Jobs/ProxyStartJob.php b/app/Jobs/ProxyStartJob.php
index 4e2331a681..91932a48c2 100755
--- a/app/Jobs/ProxyStartJob.php
+++ b/app/Jobs/ProxyStartJob.php
@@ -3,6 +3,8 @@
namespace App\Jobs;
use App\Actions\Proxy\StartProxy;
+use App\Enums\ProxyStatus;
+use App\Enums\ProxyTypes;
use App\Models\Server;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -27,6 +29,11 @@ class ProxyStartJob implements ShouldQueue
if ($status === 'running') {
return;
}
+ if (is_null(data_get($this->server, 'proxy.type'))) {
+ $this->server->proxy->type = ProxyTypes::TRAEFIK_V2->value;
+ $this->server->proxy->status = ProxyStatus::EXITED->value;
+ $this->server->save();
+ }
resolve(StartProxy::class)($this->server);
} catch (\Throwable $th) {
send_internal_notification('ProxyStartJob failed with: ' . $th->getMessage());