Skip to content

Commit

Permalink
added handling for 0 and 1 handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
mira-miracoli committed Mar 27, 2024
1 parent 3b13238 commit 66dc813
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions parts/24-gunicorn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,26 @@ gunicorn_handler-restart() {
readarray -t gunicorns < <(systemctl list-units --state=running | grep galaxy-gunicorn | cut -d '@' -f2 | cut -d '.' -f1)

# Calculate batch size
# batch_size=$(( (${#gunicorns[@]} + 1) / 2 ))
batch_size=$(( (${#gunicorns[@]} - 1) / 2 + 1))

batch_size=$(( (${#gunicorns[@]} + 1) / 2 ))
if ((${#gunicorns[@]} < 2)); then
echo "You have too few Gunicorn handlers to restart in batch mode. Please restart manually."
exit 1
fi
# Construct service name ranges for each batch
batch1=""
batch2=""
for ((i = 0; i < ${#gunicorns[@]} - 1; i++)); do
for ((i = 0; i < ${#gunicorns[@]}; i++)); do
if ((i < batch_size)); then
batch1+="galaxy-gunicorn@${gunicorns[i]}.service "
else
batch2+="galaxy-gunicorn@${gunicorns[i]}.service "
fi
done
echo "Found handlers: $batch1 and $batch2"
# Restart each batch
if systemctl status $batch1 | grep "GET" | grep "200" >/dev/null
then
echo "First restarting: $batch2"
echo "First restarting: $batch2"
systemctl restart $batch2
while true
do
Expand Down

0 comments on commit 66dc813

Please sign in to comment.