feat: gateway management scripts (start, stop, status)
This commit is contained in:
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/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
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
# Check Mortdecai gateway status
|
||||
echo "=== Gateway ==="
|
||||
STATUS=$(curl -sf http://localhost:8500/v2/status 2>/dev/null)
|
||||
if [ -n "$STATUS" ]; then
|
||||
echo "$STATUS" | python3 -m json.tool 2>/dev/null || echo "$STATUS"
|
||||
else
|
||||
echo "DOWN — gateway not reachable on port 8500"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=== Process ==="
|
||||
pgrep -f "uvicorn gateway.api" -a 2>/dev/null || echo "Not running"
|
||||
|
||||
echo ""
|
||||
echo "=== Recent Logs (errors only) ==="
|
||||
grep -i "error\|warning\|traceback" /tmp/mortdecai-gateway.log 2>/dev/null | tail -5 || echo "No log file"
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
# Stop the Mortdecai gateway
|
||||
PID_FILE="/tmp/mortdecai-gateway.pid"
|
||||
|
||||
if [ -f "$PID_FILE" ]; then
|
||||
PID=$(cat "$PID_FILE")
|
||||
if kill -0 "$PID" 2>/dev/null; then
|
||||
kill "$PID"
|
||||
echo "Gateway stopped (PID $PID)"
|
||||
else
|
||||
echo "Gateway not running (stale PID file)"
|
||||
fi
|
||||
rm -f "$PID_FILE"
|
||||
else
|
||||
# Fallback: find by process name
|
||||
PID=$(pgrep -f "uvicorn gateway.api" 2>/dev/null | head -1)
|
||||
if [ -n "$PID" ]; then
|
||||
kill "$PID"
|
||||
echo "Gateway stopped (PID $PID)"
|
||||
else
|
||||
echo "Gateway not running"
|
||||
fi
|
||||
fi
|
||||
Reference in New Issue
Block a user