Spaces:
Running
Running
File size: 803 Bytes
3193174 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #!/bin/bash
set -e
# Create data directories
mkdir -p "$GMAS_DATA_DIR/agents" "$GMAS_DATA_DIR/graphs" "$GMAS_DATA_DIR/runs"
# Create nginx temp directories
mkdir -p /tmp/nginx/body /tmp/nginx/proxy /tmp/nginx/fastcgi /tmp/nginx/uwsgi /tmp/nginx/scgi
# Start uvicorn in the background
uvicorn backend.main:app \
--host 127.0.0.1 \
--port 8000 \
--workers "${GMAS_WORKERS:-1}" &
UVICORN_PID=$!
# Start nginx in the foreground (use full config, not sites-enabled)
nginx -c /etc/nginx/sites-available/default -g "daemon off;" &
NGINX_PID=$!
# Forward signals to both processes
trap 'kill $UVICORN_PID $NGINX_PID 2>/dev/null; wait' TERM INT
# Wait for either process to exit; if one dies, stop the other
wait -n $UVICORN_PID $NGINX_PID
kill $UVICORN_PID $NGINX_PID 2>/dev/null || true
wait
|