@@ -469,22 +469,26 @@ EOF
469
469
fi
470
470
471
471
echo " 10. Stopping postgres; running pg_upgrade"
472
- # Extra work to ensure postgres is actually stopped
473
- # Mostly needed for PG12 projects with odd systemd unit behavior
472
+ # Stop PostgreSQL service
474
473
if [ -z " $IS_CI " ]; then
475
- retry 5 systemctl restart postgresql
474
+ echo " Stopping PostgreSQL service..."
475
+
476
+ # Disable service first so it doesn't restart automatically
476
477
systemctl disable postgresql
477
- retry 5 systemctl stop postgresql
478
-
479
- sleep 3
480
- systemctl stop postgresql
481
478
482
- # Additional check to ensure postgres is really stopped
483
- if [ -f " ${PGDATAOLD} /postmaster.pid" ]; then
484
- echo " PostgreSQL still running, forcing stop..."
485
- pid=$( head -n 1 " ${PGDATAOLD} /postmaster.pid" )
486
- kill -9 " $pid " || true
487
- rm -f " ${PGDATAOLD} /postmaster.pid"
479
+ # Use systemctl stop with a longer timeout
480
+ if ! systemctl stop -t 120 postgresql; then
481
+ echo " Standard stop failed, trying one more time..."
482
+ sleep 5
483
+ systemctl stop -t 120 postgresql || true
484
+ fi
485
+
486
+ # Quick verification
487
+ if systemctl is-active --quiet postgresql; then
488
+ echo " WARNING: PostgreSQL service still active after stop commands"
489
+ echo " You may need to investigate what's preventing proper shutdown"
490
+ else
491
+ echo " PostgreSQL successfully stopped"
488
492
fi
489
493
else
490
494
CI_stop_postgres
0 commit comments