92 lines
2.5 KiB
Bash
92 lines
2.5 KiB
Bash
|
|
#!/bin/bash
|
||
|
|
# Dolphin Supervisor Control Script
|
||
|
|
# Wrapper around supervisorctl for easy management
|
||
|
|
|
||
|
|
CONFIG="/mnt/dolphinng5_predict/prod/supervisor/dolphin-supervisord.conf"
|
||
|
|
PIDFILE="/mnt/dolphinng5_predict/prod/supervisor/run/supervisord.pid"
|
||
|
|
SOCKFILE="/tmp/dolphin-supervisor.sock"
|
||
|
|
|
||
|
|
usage() {
|
||
|
|
echo "Dolphin Service Supervisor (using Supervisor)"
|
||
|
|
echo ""
|
||
|
|
echo "Usage: $0 {start|stop|restart|status|logs|ctl} [args]"
|
||
|
|
echo ""
|
||
|
|
echo "Commands:"
|
||
|
|
echo " start Start supervisord and all services"
|
||
|
|
echo " stop Stop all services and supervisord"
|
||
|
|
echo " restart Restart all services"
|
||
|
|
echo " status Show status of all services"
|
||
|
|
echo " logs [service] Show logs (optionally filter by service)"
|
||
|
|
echo " ctl [cmd] Pass command to supervisorctl"
|
||
|
|
echo ""
|
||
|
|
echo "Examples:"
|
||
|
|
echo " $0 start # Start everything"
|
||
|
|
echo " $0 status # Show all service status"
|
||
|
|
echo " $0 logs exf # Show ExF logs"
|
||
|
|
echo " $0 ctl restart exf # Restart just ExF"
|
||
|
|
echo " $0 ctl tail -f exf # Follow ExF logs"
|
||
|
|
}
|
||
|
|
|
||
|
|
start_supervisor() {
|
||
|
|
if [ -f "$PIDFILE" ] && kill -0 $(cat "$PIDFILE") 2>/dev/null; then
|
||
|
|
echo "Supervisor already running (PID: $(cat $PIDFILE))"
|
||
|
|
else
|
||
|
|
echo "Starting supervisor..."
|
||
|
|
mkdir -p /mnt/dolphinng5_predict/prod/supervisor/logs
|
||
|
|
mkdir -p /mnt/dolphinng5_predict/prod/supervisor/run
|
||
|
|
supervisord -c "$CONFIG"
|
||
|
|
sleep 2
|
||
|
|
echo "Supervisor started"
|
||
|
|
fi
|
||
|
|
show_status
|
||
|
|
}
|
||
|
|
|
||
|
|
stop_supervisor() {
|
||
|
|
echo "Stopping all services..."
|
||
|
|
supervisorctl -c "$CONFIG" stop all
|
||
|
|
echo "Stopping supervisor..."
|
||
|
|
supervisorctl -c "$CONFIG" shutdown
|
||
|
|
echo "Stopped"
|
||
|
|
}
|
||
|
|
|
||
|
|
show_status() {
|
||
|
|
echo "=== Dolphin Services Status ==="
|
||
|
|
supervisorctl -c "$CONFIG" status
|
||
|
|
}
|
||
|
|
|
||
|
|
show_logs() {
|
||
|
|
if [ -z "$2" ]; then
|
||
|
|
echo "=== All Logs (last 50 lines) ==="
|
||
|
|
tail -n 50 /mnt/dolphinng5_predict/prod/supervisor/logs/supervisord.log
|
||
|
|
else
|
||
|
|
echo "=== $2 Logs (last 50 lines) ==="
|
||
|
|
tail -n 50 "/mnt/dolphinng5_predict/prod/supervisor/logs/$2.log"
|
||
|
|
fi
|
||
|
|
}
|
||
|
|
|
||
|
|
case "$1" in
|
||
|
|
start)
|
||
|
|
start_supervisor
|
||
|
|
;;
|
||
|
|
stop)
|
||
|
|
stop_supervisor
|
||
|
|
;;
|
||
|
|
restart)
|
||
|
|
supervisorctl -c "$CONFIG" restart all
|
||
|
|
;;
|
||
|
|
status)
|
||
|
|
show_status
|
||
|
|
;;
|
||
|
|
logs)
|
||
|
|
show_logs "$@"
|
||
|
|
;;
|
||
|
|
ctl)
|
||
|
|
shift
|
||
|
|
supervisorctl -c "$CONFIG" "$@"
|
||
|
|
;;
|
||
|
|
*)
|
||
|
|
usage
|
||
|
|
exit 1
|
||
|
|
;;
|
||
|
|
esac
|