#!/bin/bash # # Start AI Services with Supervisor # Starts supervisor daemon which manages ComfyUI and orchestrator # set -e WORKSPACE_DIR="${WORKSPACE_DIR:-/workspace}" SUPERVISORD_CONF="${WORKSPACE_DIR}/supervisord.conf" AI_DIR="${WORKSPACE_DIR}/ai" cd "${AI_DIR}" echo "=========================================" echo " Starting AI Services with Supervisor" echo "=========================================" echo "" # Check for .env file if [ ! -f .env ]; then echo "Warning: .env file not found" echo "Copy .env.example to .env and add your configuration" echo "" fi # Source .env if it exists if [ -f .env ]; then set -a source .env set +a fi # Check if supervisord is already running if [ -f "${WORKSPACE_DIR}/supervisord.pid" ]; then PID=$(cat "${WORKSPACE_DIR}/supervisord.pid") if ps -p "$PID" > /dev/null 2>&1; then echo "Supervisor is already running (PID: $PID)" echo "" echo "Checking service status..." supervisorctl -c "${SUPERVISORD_CONF}" status exit 0 else echo "Removing stale PID file..." rm -f "${WORKSPACE_DIR}/supervisord.pid" fi fi # Start supervisord echo "Starting Supervisor daemon..." supervisord -c "${SUPERVISORD_CONF}" # Wait a moment for supervisor to start sleep 2 # Check status echo "" echo "Service Status:" echo "---------------" supervisorctl -c "${SUPERVISORD_CONF}" status echo "" echo "=========================================" echo "Services started successfully!" echo "=========================================" echo "" echo "Useful commands:" echo " supervisorctl status - Check status" echo " supervisorctl start orchestrator - Start orchestrator" echo " supervisorctl restart comfyui - Restart ComfyUI" echo " supervisorctl stop all - Stop all services" echo " supervisorctl tail -f comfyui - Follow ComfyUI logs" echo "" echo "Web interface: http://localhost:9001" echo " Username: admin" echo " Password: runpod2024" echo ""