diff --git a/run-server-3002.sh b/run-server-3002.sh index e5a4bbe8..3fcbf6bf 100755 --- a/run-server-3002.sh +++ b/run-server-3002.sh @@ -1,30 +1,42 @@ #!/usr/bin/env bash -# Start production server via launchd +# Start production server (port 3002) set -euo pipefail -case "${1:-}" in - stop) - echo "Stopping production server and worker..." - launchctl bootout gui/$(id -u)/com.momentry.server 2>/dev/null || true - launchctl bootout gui/$(id -u)/com.momentry.worker 2>/dev/null || true - echo "Stopped." - ;; - restart) - "$0" stop - "$0" start - ;; - status) - echo "=== Server ===" - launchctl list com.momentry.server 2>/dev/null | head -5 || echo "Not loaded" - echo "=== Worker ===" - launchctl list com.momentry.worker 2>/dev/null | head -5 || echo "Not loaded" - echo "=== Health ===" - curl -s --max-time 3 http://localhost:3002/api/v1/health 2>/dev/null || echo "No response" - ;; - *) - echo "Starting production server and worker via launchd..." - launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.momentry.server.plist 2>/dev/null || launchctl load ~/Library/LaunchAgents/com.momentry.server.plist - launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.momentry.worker.plist 2>/dev/null || launchctl load ~/Library/LaunchAgents/com.momentry.worker.plist - echo "Done. Use '$0 status' to check." - ;; -esac +cd /Users/accusys/momentry_core + +# Kill existing processes +pkill -f "target/debug/momentry server" 2>/dev/null || true +pkill -f "target/debug/momentry worker" 2>/dev/null || true +sleep 2 + +# Start server +echo "Starting server on port 3002..." +export MOMENTRY_SERVER_PORT=3002 +export MOMENTRY_REDIS_PREFIX=momentry: +export DATABASE_SCHEMA=public +export MOMENTRY_OUTPUT_DIR=/Users/accusys/momentry/output + +nohup ./target/debug/momentry server > logs/momentry_3002.log 2>&1 & +SERVER_PID=$! +echo "Server PID: $SERVER_PID" + +sleep 2 + +# Start worker +echo "Starting worker with max_concurrent=6..." +nohup ./target/debug/momentry worker \ + --max-concurrent 6 \ + --poll-interval 5 \ + --batch-size 10 \ + > logs/worker_3002.log 2>&1 & +WORKER_PID=$! +echo "Worker PID: $WORKER_PID" + +sleep 2 + +# Verify +echo "" +echo "=== Status ===" +ps aux | grep -E "momentry (server|worker)" | grep -v grep +echo "" +echo "✅ Server and Worker started on port 3002"