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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix: Stop resources gracefully
Andras Bacsaie897eb299916
diff --git a/app/Actions/Application/StopApplication.php b/app/Actions/Application/StopApplication.phpindex 1f05e29ac7..7155f9a0a2 100644--- a/app/Actions/Application/StopApplication.php+++ b/app/Actions/Application/StopApplication.php@@ -31,15 +31,13 @@ class StopApplication} else {$containers = getCurrentApplicationContainerStatus($server, $application->id, 0);}- ray($containers);if ($containers->count() > 0) {foreach ($containers as $container) {$containerName = data_get($container, 'Names');if ($containerName) {- instant_remote_process(- ["docker rm -f {$containerName}"],- $server- );+ instant_remote_process(command: ["docker stop --time=30 $containerName"], server: $server, throwError: false);+ instant_remote_process(command: ["docker rm $containerName"], server: $server, throwError: false);+ instant_remote_process(command: ["docker rm -f {$containerName}"], server: $server, throwError: false);}}}diff --git a/app/Actions/Database/StopDatabase.php b/app/Actions/Database/StopDatabase.phpindex e4903ff35d..d562ec56fe 100644--- a/app/Actions/Database/StopDatabase.php+++ b/app/Actions/Database/StopDatabase.php@@ -22,10 +22,11 @@ class StopDatabaseif (! $server->isFunctional()) {return 'Server is not functional';}- instant_remote_process(- ["docker rm -f {$database->uuid}"],- $server- );++ instant_remote_process(command: ["docker stop --time=30 $database->uuid"], server: $server, throwError: false);+ instant_remote_process(command: ["docker rm $database->uuid"], server: $server, throwError: false);+ instant_remote_process(command: ["docker rm -f $database->uuid"], server: $server, throwError: false);+if ($database->is_public) {StopDatabaseProxy::run($database);}diff --git a/app/Actions/Service/StopService.php b/app/Actions/Service/StopService.phpindex c7b1170a74..3dd91b4e24 100644--- a/app/Actions/Service/StopService.php+++ b/app/Actions/Service/StopService.php@@ -19,18 +19,21 @@ class StopServiceray('Stopping service: '.$service->name);$applications = $service->applications()->get();foreach ($applications as $application) {- instant_remote_process(["docker rm -f {$application->name}-{$service->uuid}"], $service->server, false);+ instant_remote_process(command: ["docker stop --time=30 {$application->name}-{$service->uuid}"], server: $server, throwError: false);+ instant_remote_process(command: ["docker rm {$application->name}-{$service->uuid}"], server: $server, throwError: false);+ instant_remote_process(command: ["docker rm -f {$application->name}-{$service->uuid}"], server: $server, throwError: false);$application->update(['status' => 'exited']);}$dbs = $service->databases()->get();foreach ($dbs as $db) {- instant_remote_process(["docker rm -f {$db->name}-{$service->uuid}"], $service->server, false);+ instant_remote_process(command: ["docker stop --time=30 {$db->name}-{$service->uuid}"], server: $server, throwError: false);+ instant_remote_process(command: ["docker rm {$db->name}-{$service->uuid}"], server: $server, throwError: false);+ instant_remote_process(command: ["docker rm -f {$db->name}-{$service->uuid}"], server: $server, throwError: false);$db->update(['status' => 'exited']);}instant_remote_process(["docker network disconnect {$service->uuid} coolify-proxy"], $service->server);instant_remote_process(["docker network rm {$service->uuid}"], $service->server);} catch (\Exception $e) {- echo $e->getMessage();ray($e->getMessage());return $e->getMessage();diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.phpindex fad5ad1850..473cbc679c 100644--- a/app/Jobs/ApplicationDeploymentJob.php+++ b/app/Jobs/ApplicationDeploymentJob.php@@ -2030,7 +2030,7 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");/*** @param int $timeout in seconds*/- private function graceful_shutdown_container(string $containerName, int $timeout = 60)+ private function graceful_shutdown_container(string $containerName, int $timeout = 30){try {$this->execute_remote_command(