Skip to content

Commit

Permalink
fix: use timeout in cleanup resources
Browse files Browse the repository at this point in the history
  • Loading branch information
andrasbacsai committed Jan 10, 2025
1 parent 5c8b26d commit f748fba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/Console/Commands/CleanupStuckedResources.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions app/Jobs/CleanupHelperContainersJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit f748fba

Please sign in to comment.