evOo-local/deploy.sh
cynarAI 6c7eed7580 Initial clean evOo-local from f00577b
Fresh history cut from cynarAI/evoo antigravity-handoff/project-timeline
(Voice First + project timeline). Brand docs/titles as evOo; keep @rakazo/*
packages as tech debt. Excludes node_modules, caches, secrets, voice blobs.
2026-09-20 17:15:16 +02:00

139 lines
5.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# ==============================================================================
# evOo Platform — Hot-Reload & Physical Deployment Orchestrator
# Executive Lead: CTO Steve Jobs
# "Realität im Dateisystem vor Halluzination im Kopf."
# ==============================================================================
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PORT="${PORT:-3088}"
PID_FILE="${SCRIPT_DIR}/.evoo_server.pid"
LOG_FILE="${SCRIPT_DIR}/deploy.log"
# Colors
GREEN='\033[0;32m'
CYAN='\033[0;36m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
log() {
echo -e "${CYAN}[evOo Deploy]${NC} $1"
}
success() {
echo -e "${GREEN}[✓ SUCCESS]${NC} $1"
}
warn() {
echo -e "${YELLOW}[⚠ WARNING]${NC} $1"
}
fail() {
echo -e "${RED}[✗ FAILED]${NC} $1" >&2
exit 1
}
echo "=========================================================="
echo " evOo Autonomous Platform — Hot-Reload & Deploy "
echo " CTO: Steve Jobs | Port: ${PORT} "
echo "=========================================================="
# ------------------------------------------------------------------------------
# STEP 1: Physical Reality & Filesystem Audit (Zero Phantom Policy)
# ------------------------------------------------------------------------------
log "Prüfe physische Existenz aller Kern-Artefakte..."
REQUIRED_FILES=(
"${SCRIPT_DIR}/ARCHITECTURE.md"
"${SCRIPT_DIR}/evoo.config.json"
"${SCRIPT_DIR}/evoo-platform/index.html"
"${SCRIPT_DIR}/evoo-platform/styles.css"
"${SCRIPT_DIR}/evoo-platform/app.js"
"${SCRIPT_DIR}/evoo-platform/server.js"
"${SCRIPT_DIR}/apex-trading/BLUEPRINT.md"
"${SCRIPT_DIR}/apex-trading/config/trading.config.json"
"${SCRIPT_DIR}/orchestrator/agents.json"
"${SCRIPT_DIR}/orchestrator/agent_runner.py"
)
for file in "${REQUIRED_FILES[@]}"; do
if [[ ! -f "$file" ]]; then
fail "Physische Datei fehlt im Dateisystem: $file. Abbruch! Vision-Schleife verhindert."
fi
done
success "100% Physische Dateisystem-Integrität bestätigt. Keine Phantom-Dateien."
# If user only wanted verification
if [[ "${1:-}" == "--check-only" ]]; then
success "Check-only abgeschlossen. Alles physisch vorhanden."
exit 0
fi
# ------------------------------------------------------------------------------
# STEP 2: Process Management / Hot-Reload
# ------------------------------------------------------------------------------
if [[ -f "$PID_FILE" ]]; then
OLD_PID="$(cat "$PID_FILE" 2>/dev/null || true)"
if [[ -n "$OLD_PID" ]] && kill -0 "$OLD_PID" 2>/dev/null; then
log "Beende vorherige Server-Instanz (PID: $OLD_PID) für Hot-Reload..."
kill "$OLD_PID" 2>/dev/null || true
sleep 0.5
fi
rm -f "$PID_FILE"
fi
# Also ensure port is free
OCCUPIED_PID="$(lsof -ti tcp:"$PORT" 2>/dev/null || true)"
if [[ -n "$OCCUPIED_PID" ]]; then
log "Port $PORT bereits belegt von PID $OCCUPIED_PID. Bereinige..."
kill -9 $OCCUPIED_PID 2>/dev/null || true
sleep 0.5
fi
# ------------------------------------------------------------------------------
# STEP 3: Server Start
# ------------------------------------------------------------------------------
log "Starte evOo Platform Server als robuster Daemon auf Port ${PORT}..."
export PORT
if [[ "${1:-}" == "serve" || "${1:-}" == "--foreground" ]]; then
echo "$$" > "$PID_FILE"
log "Server läuft im Vordergrund (Strg+C zum Beenden)..."
exec node "${SCRIPT_DIR}/evoo-platform/server.js"
fi
# True detached POSIX daemon via setsid
python3 -c "import subprocess; subprocess.Popen(['node', '${SCRIPT_DIR}/evoo-platform/server.js'], cwd='${SCRIPT_DIR}', start_new_session=True, stdout=open('${LOG_FILE}', 'a'), stderr=subprocess.STDOUT)"
# Wait up to 5 seconds for healthcheck
log "Führe Healthcheck durch (http://127.0.0.1:${PORT}/health)..."
for i in {1..10}; do
if curl -s "http://127.0.0.1:${PORT}/health" >/dev/null 2>&1; then
HEALTH_RES="$(curl -s "http://127.0.0.1:${PORT}/health")"
success "Platform Server antwortet: HTTP 200 OK!"
echo -e "${CYAN}Health Response:${NC} $HEALTH_RES"
break
fi
if [[ $i -eq 10 ]]; then
fail "Server antwortet nicht innerhalb des Timeouts! Überprüfe $LOG_FILE"
fi
sleep 0.5
done
# ------------------------------------------------------------------------------
SERVER_PID="$(cat "$PID_FILE" 2>/dev/null || echo "active")"
echo ""
echo -e "${GREEN}==========================================================${NC}"
echo -e "${GREEN} evOo PLATFORM ERFOLGREICH DEPLOYED & LIVE! ${NC}"
echo -e "${GREEN}==========================================================${NC}"
echo -e " 🌐 Dashboard: ${CYAN}http://127.0.0.1:${PORT}/${NC}"
echo -e " 💓 Healthcheck: ${CYAN}http://127.0.0.1:${PORT}/health${NC}"
echo -e " 📊 Telemetrie API: ${CYAN}http://127.0.0.1:${PORT}/api/status${NC}"
echo -e " 📑 Verfassung: ${CYAN}${SCRIPT_DIR}/ARCHITECTURE.md${NC}"
echo -e " 📈 Apex Trading: ${CYAN}${SCRIPT_DIR}/apex-trading/BLUEPRINT.md${NC}"
echo -e " ⚙️ PID: ${SERVER_PID}"
echo -e "${GREEN}==========================================================${NC}"