feat: add retry logic for PHP-FPM restart with optimization fallback
This commit is contained in:
21
gitapply.sh
21
gitapply.sh
@@ -244,7 +244,7 @@ run_remote_update() {
|
|||||||
echo "pending" > "$status_file"
|
echo "pending" > "$status_file"
|
||||||
|
|
||||||
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 -o BatchMode=yes -i "$SSH_KEY" root@"$node" \
|
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 -o BatchMode=yes -i "$SSH_KEY" root@"$node" \
|
||||||
'cd /var/www/paymenter && git pull && npm update && npm upgrade && composer upgrade && php artisan view:clear && php artisan cache:clear && php artisan optimize && systemctl restart php8.3-fpm' \
|
'cd /var/www/paymenter && git pull && npm update && npm upgrade && composer upgrade && php artisan view:clear && php artisan cache:clear && php artisan optimize && while ! systemctl restart php8.3-fpm 2>/dev/null; do echo "PHP-FPM restart failed, running optimize and retrying..."; php artisan optimize; sleep 1; done' \
|
||||||
> "$STATUS_DIR/${node}.log" 2>&1
|
> "$STATUS_DIR/${node}.log" 2>&1
|
||||||
|
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
@@ -547,9 +547,22 @@ task_done "Optimization completed"
|
|||||||
# Restart PHP-FPM
|
# Restart PHP-FPM
|
||||||
task_start "Local: Restarting Services"
|
task_start "Local: Restarting Services"
|
||||||
printf " ${C3}○${NC} PHP 8.3 FPM..."
|
printf " ${C3}○${NC} PHP 8.3 FPM..."
|
||||||
systemctl restart php8.3-fpm &
|
|
||||||
spinner $! "PHP 8.3 FPM"
|
# Retry loop: if PHP-FPM fails to restart, run optimize and try again
|
||||||
task_done "PHP 8.3 FPM restarted"
|
php_restart_success=false
|
||||||
|
php_restart_attempts=0
|
||||||
|
while [ "$php_restart_success" = false ]; do
|
||||||
|
php_restart_attempts=$((php_restart_attempts + 1))
|
||||||
|
if systemctl restart php8.3-fpm > /dev/null 2>&1; then
|
||||||
|
php_restart_success=true
|
||||||
|
else
|
||||||
|
printf "\r ${YELLOW}○${NC} PHP 8.3 FPM restart failed (attempt ${php_restart_attempts}), running optimize...\n"
|
||||||
|
php artisan optimize > /dev/null 2>&1
|
||||||
|
printf " ${C3}○${NC} Retrying PHP 8.3 FPM..."
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
task_done "PHP 8.3 FPM restarted (attempt ${php_restart_attempts})"
|
||||||
|
|
||||||
# Wait for remote nodes
|
# Wait for remote nodes
|
||||||
task_start "Waiting for Remote Nodes"
|
task_start "Waiting for Remote Nodes"
|
||||||
|
|||||||
Reference in New Issue
Block a user