Includes core prod + GREEN/BLUE subsystems: - prod/ (BLUE harness, configs, scripts, docs) - nautilus_dolphin/ (GREEN Nautilus-native impl + dvae/ preserved) - adaptive_exit/ (AEM engine + models/bucket_assignments.pkl) - Observability/ (EsoF advisor, TUI, dashboards) - external_factors/ (EsoF producer) - mc_forewarning_qlabs_fork/ (MC regime/envelope) Excludes runtime caches, logs, backups, and reproducible artifacts per .gitignore.
144 lines
3.3 KiB
Bash
Executable File
144 lines
3.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# DOLPHIN Service Manager
|
|
# =======================
|
|
# Manages all production services per SYSTEM_BIBLE Section 16
|
|
# Ensures services restart if they fail
|
|
|
|
LOG_DIR="/tmp/dolphin_services"
|
|
mkdir -p $LOG_DIR
|
|
|
|
# Service definitions: "name:script:hz_key"
|
|
SERVICES=(
|
|
"scan_bridge:scan_bridge_service.py:latest_eigen_scan"
|
|
"acb_processor:acb_processor_service.py:acb_boost"
|
|
"system_watchdog:system_watchdog_service.py:safety"
|
|
"extf:exf_prefect_final.py:exf_latest"
|
|
)
|
|
|
|
start_service() {
|
|
local name=$1
|
|
local script=$2
|
|
|
|
if pgrep -f "$script" > /dev/null; then
|
|
echo "✅ $name already running (PID: $(pgrep -f $script | head -1))"
|
|
return 0
|
|
fi
|
|
|
|
echo "🚀 Starting $name..."
|
|
source /home/dolphin/siloqy_env/bin/activate
|
|
nohup python3 "$script" > "$LOG_DIR/${name}.log" 2>&1 &
|
|
sleep 2
|
|
|
|
if pgrep -f "$script" > /dev/null; then
|
|
echo "✅ $name started (PID: $(pgrep -f $script | head -1))"
|
|
return 0
|
|
else
|
|
echo "❌ $name failed to start"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
stop_service() {
|
|
local name=$1
|
|
local script=$2
|
|
|
|
echo "🛑 Stopping $name..."
|
|
pkill -f "$script" 2>/dev/null
|
|
sleep 1
|
|
|
|
if pgrep -f "$script" > /dev/null; then
|
|
pkill -9 -f "$script" 2>/dev/null
|
|
fi
|
|
|
|
echo "✅ $name stopped"
|
|
}
|
|
|
|
status() {
|
|
echo "🐬 DOLPHIN Services Status"
|
|
echo "=========================="
|
|
echo ""
|
|
|
|
for svc in "${SERVICES[@]}"; do
|
|
IFS=':' read -r name script hz_key <<< "$svc"
|
|
pid=$(pgrep -f "$script" | head -1)
|
|
if [ -n "$pid" ]; then
|
|
uptime=$(ps -o etime= -p $pid 2>/dev/null | tr -d ' ')
|
|
echo "✅ $name - PID $pid - Uptime $uptime"
|
|
else
|
|
echo "❌ $name - NOT RUNNING"
|
|
fi
|
|
done
|
|
|
|
echo ""
|
|
echo "Logs: $LOG_DIR/"
|
|
}
|
|
|
|
start_all() {
|
|
echo "🚀 Starting all DOLPHIN services..."
|
|
echo ""
|
|
|
|
for svc in "${SERVICES[@]}"; do
|
|
IFS=':' read -r name script hz_key <<< "$svc"
|
|
start_service "$name" "$script"
|
|
done
|
|
|
|
echo ""
|
|
echo "✅ All services started"
|
|
}
|
|
|
|
stop_all() {
|
|
echo "🛑 Stopping all DOLPHIN services..."
|
|
echo ""
|
|
|
|
for svc in "${SERVICES[@]}"; do
|
|
IFS=':' read -r name script hz_key <<< "$svc"
|
|
stop_service "$name" "$script"
|
|
done
|
|
|
|
echo ""
|
|
echo "✅ All services stopped"
|
|
}
|
|
|
|
# Health check and restart
|
|
cron_check() {
|
|
for svc in "${SERVICES[@]}"; do
|
|
IFS=':' read -r name script hz_key <<< "$svc"
|
|
if ! pgrep -f "$script" > /dev/null; then
|
|
echo "$(date): $name not running, restarting..." >> "$LOG_DIR/cron.log"
|
|
start_service "$name" "$script"
|
|
fi
|
|
done
|
|
}
|
|
|
|
# Main
|
|
case "$1" in
|
|
start)
|
|
start_all
|
|
;;
|
|
stop)
|
|
stop_all
|
|
;;
|
|
restart)
|
|
stop_all
|
|
sleep 2
|
|
start_all
|
|
;;
|
|
status)
|
|
status
|
|
;;
|
|
cron)
|
|
cron_check
|
|
;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|restart|status|cron}"
|
|
echo ""
|
|
echo "Commands:"
|
|
echo " start - Start all services"
|
|
echo " stop - Stop all services"
|
|
echo " restart - Restart all services"
|
|
echo " status - Show service status"
|
|
echo " cron - Health check & restart (for cron job)"
|
|
exit 1
|
|
;;
|
|
esac
|