#!/bin/bash # AGIAGI - Start All Services # Starts API, Stream, Agent, and existing daemons echo "============================================" echo "AGIAGI - Starting All Services" echo "============================================" THATAIGUY_HOME="${HOME}/.agi_core" API_DIR="${HOME}/AGICore/api" LOG_DIR="/tmp/agi_core_logs" PID_DIR="${THATAIGUY_HOME}/pids" mkdir -p "$LOG_DIR" "$PID_DIR" # Kill existing services on our ports echo "[Startup] Cleaning up existing services..." lsof -ti:8000 | xargs kill -9 2>/dev/null || true lsof -ti:8001 | xargs kill -9 2>/dev/null || true sleep 1 # 1. Start API Server (port 8000) echo "[Startup] Starting API Server on port 8000..." cd "$API_DIR" python3 server.py >> "${LOG_DIR}/api.log" 2>&1 & echo $! > "${PID_DIR}/api.pid" echo " PID: $(cat ${PID_DIR}/api.pid)" # 2. Start WebSocket Stream (port 8001) echo "[Startup] Starting Consciousness Stream on port 8001..." python3 stream.py >> "${LOG_DIR}/stream.log" 2>&1 & echo $! > "${PID_DIR}/stream.pid" echo " PID: $(cat ${PID_DIR}/stream.pid)" # 3. Start Agent Daemon (optional - uncomment to auto-start) # echo "[Startup] Starting Agent Daemon..." # python3 agent.py >> "${LOG_DIR}/agent.log" 2>&1 & # echo $! > "${PID_DIR}/agent.pid" # echo " PID: $(cat ${PID_DIR}/agent.pid)" # 4. Start Mesh Sync Daemon (federation with MacBook 2) echo "[Startup] Starting Mesh Sync Daemon..." pkill -f mesh-sync-daemon 2>/dev/null || true ${HOME}/AGICore/scripts/mesh-sync-daemon.sh >> "${THATAIGUY_HOME}/logs/mesh-sync.log" 2>&1 & echo $! > "${PID_DIR}/mesh-sync.pid" echo " PID: $(cat ${PID_DIR}/mesh-sync.pid)" # Wait for services to start sleep 2 # Verify services echo "" echo "============================================" echo "Service Status:" echo "============================================" # Check API if curl -s http://localhost:8000/health > /dev/null 2>&1; then echo " [OK] API Server: http://localhost:8000" else echo " [FAIL] API Server" fi # Check Stream if lsof -i:8001 > /dev/null 2>&1; then echo " [OK] Stream Server: ws://localhost:8001/consciousness" else echo " [FAIL] Stream Server" fi # Check Mesh Sync if pgrep -f mesh-sync-daemon > /dev/null 2>&1; then echo " [OK] Mesh Sync: Syncing with MacBook 2 every 5s" else echo " [FAIL] Mesh Sync Daemon" fi echo "" echo "Endpoints:" echo " API: http://localhost:8000" echo " Status: http://localhost:8000/status" echo " Chat: http://localhost:8000/chat" echo " Agent: http://localhost:8000/agent/status" echo " Stream: ws://localhost:8001/consciousness" echo " Test UI: file://${API_DIR}/stream_test.html" echo "" echo "Logs: ${LOG_DIR}/" echo "============================================"