finish 799 B

1234567891011121314151617181920212223242526272829
  1. #!/command/with-contenv bash
  2. EXIT_CODE="$1"
  3. EXIT_SIGNAL="$2"
  4. SCRIPT_ROOT=/etc/s6-overlay/scripts
  5. source "$SCRIPT_ROOT/base.sh"
  6. # The config should be ready before starting
  7. source "$GPUSTACK_POSTGRES_CONFIG"
  8. source "$SCRIPT_ROOT/default-variables.sh"
  9. PGDATA="${POSTGRES_DATA_DIR}"
  10. echo "[INFO] PostgreSQL service is stopping..."
  11. if [ -f "$PGDATA/postmaster.pid" ]; then
  12. echo "[ERROR] Gracefully shutting down PostgreSQL..."
  13. gosu postgres pg_ctl -D "$PGDATA" -m fast stop || \
  14. gosu postgres pg_ctl -D "$PGDATA" -m immediate stop
  15. sleep 2
  16. fi
  17. if [ -f "$PGDATA/postmaster.pid" ]; then
  18. echo "[ERROR] PostgreSQL did not exit cleanly. Forcing immediate shutdown."
  19. gosu postgres pg_ctl -D "$PGDATA" -m immediate stop
  20. fi
  21. handleServiceExit "postgres" "$EXIT_CODE" "$EXIT_SIGNAL"