Files
runpod/scripts/stop-all.sh

50 lines
1.3 KiB
Bash
Raw Normal View History

#!/bin/bash
#
# Stop AI Services
# Gracefully stops all services managed by Supervisor
#
set -e
WORKSPACE_DIR="${WORKSPACE_DIR:-/workspace}"
SUPERVISORD_CONF="${WORKSPACE_DIR}/supervisord.conf"
echo "========================================="
echo " Stopping AI Services"
echo "========================================="
echo ""
# Check if supervisord is running
if [ ! -f "${WORKSPACE_DIR}/supervisord.pid" ]; then
echo "Supervisor is not running (no PID file found)"
echo "Cleaning up any stray processes..."
pkill -f "orchestrator_subprocess.py" || echo " - Orchestrator not running"
pkill -f "ComfyUI.*main.py" || echo " - ComfyUI not running"
echo ""
echo "All services stopped"
exit 0
fi
PID=$(cat "${WORKSPACE_DIR}/supervisord.pid")
if ! ps -p "$PID" > /dev/null 2>&1; then
echo "Supervisor PID file exists but process is not running"
echo "Removing stale PID file..."
rm -f "${WORKSPACE_DIR}/supervisord.pid"
echo ""
echo "All services stopped"
exit 0
fi
# Stop all supervised services
echo "Stopping all supervised services..."
supervisorctl -c "${SUPERVISORD_CONF}" stop all
sleep 2
# Shutdown supervisord
echo "Shutting down Supervisor daemon..."
supervisorctl -c "${SUPERVISORD_CONF}" shutdown
echo ""
echo "All services stopped"