diff --git a/app/Console/Commands/CleanupStuckedResources.php b/app/Console/Commands/CleanupStuckedResources.php index def3d5a2c5..0b5eef84d5 100644 --- a/app/Console/Commands/CleanupStuckedResources.php +++ b/app/Console/Commands/CleanupStuckedResources.php @@ -39,6 +39,11 @@ private function cleanup_stucked_resources() $servers = Server::all()->filter(function ($server) { return $server->isFunctional(); }); + if (isCloud()) { + $servers = $servers->filter(function ($server) { + return data_get($server->team->subscription, 'stripe_invoice_paid', false) === true; + }); + } foreach ($servers as $server) { CleanupHelperContainersJob::dispatch($server); } diff --git a/app/Jobs/CleanupHelperContainersJob.php b/app/Jobs/CleanupHelperContainersJob.php index f185ab7812..0e1fcb4d75 100644 --- a/app/Jobs/CleanupHelperContainersJob.php +++ b/app/Jobs/CleanupHelperContainersJob.php @@ -20,11 +20,11 @@ public function __construct(public Server $server) {} public function handle(): void { try { - $containers = instant_remote_process(['docker container ps --format \'{{json .}}\' | jq -s \'map(select(.Image | contains("ghcr.io/coollabsio/coolify-helper")))\''], $this->server, false); + $containers = instant_remote_process_with_timeout(['docker container ps --format \'{{json .}}\' | jq -s \'map(select(.Image | contains("ghcr.io/coollabsio/coolify-helper")))\''], $this->server, false); $containerIds = collect(json_decode($containers))->pluck('ID'); if ($containerIds->count() > 0) { foreach ($containerIds as $containerId) { - instant_remote_process(['docker container rm -f '.$containerId], $this->server, false); + instant_remote_process_with_timeout(['docker container rm -f '.$containerId], $this->server, false); } } } catch (\Throwable $e) {