From 8731d0416b776681b2fb8d9188892c69e77a414d Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 11 Jun 2024 12:37:39 +0200 Subject: [PATCH] chore: Add isAnyDeploymentInprogress function to check if any deployments are in progress --- bootstrap/helpers/shared.php | 13 +++++++++++++ scripts/cloud_upgrade.sh | 9 +++++++++ 2 files changed, 22 insertions(+) create mode 100644 scripts/cloud_upgrade.sh diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 7828bf47f..9a09adee1 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -1,5 +1,7 @@ getMessage()}\n"; } } + +function isAnyDeploymentInprogress() { + // Only use it in the deployment script + $count = ApplicationDeploymentQueue::whereIn('status', [ApplicationDeploymentStatus::IN_PROGRESS, ApplicationDeploymentStatus::QUEUED])->count(); + if ($count > 0) { + echo "There are $count deployments in progress. Exiting...\n"; + exit(1); + } + echo "No deployments in progress.\n"; + exit(0); +} diff --git a/scripts/cloud_upgrade.sh b/scripts/cloud_upgrade.sh new file mode 100644 index 000000000..fc1bc959a --- /dev/null +++ b/scripts/cloud_upgrade.sh @@ -0,0 +1,9 @@ +set -e +export IMAGE=$1 +docker exec coolify sh -c "php artisan tinker --execute='isAnyDeploymentInprogress()'" +docker system prune -af +docker compose pull +read -p "Press Enter to update Coolify to $IMAGE..." last_version +docker compose logs -f