Files

32 lines
800 B
Bash
Executable File

#!/bin/bash
# Start the Mortdecai gateway (uvicorn on port 8500)
set -e
GATEWAY_DIR="$HOME/bin/Mortdecai-2.0"
PID_FILE="/tmp/mortdecai-gateway.pid"
LOG_FILE="/tmp/mortdecai-gateway.log"
# Check if already running
if [ -f "$PID_FILE" ] && kill -0 "$(cat "$PID_FILE")" 2>/dev/null; then
echo "Gateway already running (PID $(cat "$PID_FILE"))"
exit 0
fi
cd "$GATEWAY_DIR"
source .env 2>/dev/null
nohup python3 -m uvicorn gateway.api:app --host 0.0.0.0 --port 8500 > "$LOG_FILE" 2>&1 &
echo $! > "$PID_FILE"
# Wait for health
for i in $(seq 1 10); do
if curl -sf http://localhost:8500/v2/health > /dev/null 2>&1; then
echo "Gateway started (PID $(cat "$PID_FILE"))"
exit 0
fi
sleep 1
done
echo "ERROR: Gateway failed to start within 10s. Check $LOG_FILE"
exit 1