Skip to content

Commit 8731d04

Browse files
committed
chore: Add isAnyDeploymentInprogress function to check if any deployments are in progress
1 parent d051514 commit 8731d04

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

bootstrap/helpers/shared.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use App\Enums\ApplicationDeploymentStatus;
4+
use App\Models\ApplicationDeploymentQueue;
35
use App\Jobs\ServerFilesFromServerJob;
46
use App\Models\Application;
57
use App\Models\ApplicationPreview;
@@ -2268,3 +2270,14 @@ function get_public_ips()
22682270
echo "Error: {$e->getMessage()}\n";
22692271
}
22702272
}
2273+
2274+
function isAnyDeploymentInprogress() {
2275+
// Only use it in the deployment script
2276+
$count = ApplicationDeploymentQueue::whereIn('status', [ApplicationDeploymentStatus::IN_PROGRESS, ApplicationDeploymentStatus::QUEUED])->count();
2277+
if ($count > 0) {
2278+
echo "There are $count deployments in progress. Exiting...\n";
2279+
exit(1);
2280+
}
2281+
echo "No deployments in progress.\n";
2282+
exit(0);
2283+
}

scripts/cloud_upgrade.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
set -e
2+
export IMAGE=$1
3+
docker exec coolify sh -c "php artisan tinker --execute='isAnyDeploymentInprogress()'"
4+
docker system prune -af
5+
docker compose pull
6+
read -p "Press Enter to update Coolify to $IMAGE..." </dev/tty
7+
docker compose up --remove-orphans --force-recreate -d --wait
8+
echo $IMAGE > last_version
9+
docker compose logs -f

0 commit comments

Comments
 (0)