Fix start.sh: redirect uvicorn output to Docker logs

uvicorn was running in background with no output capture,
making it impossible to debug crashes. Now redirects stderr
to stdout and checks if uvicorn started successfully.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-13 14:55:04 +00:00
parent 626d39d1bb
commit bf595975bf

View File

@@ -1,13 +1,20 @@
#!/bin/sh #!/bin/sh
# Start FastAPI backend + Next.js frontend in the same container. # Start FastAPI backend + Next.js frontend in the same container.
# Uvicorn runs in the background; Node.js runs in the foreground # Both processes log to stdout/stderr so Docker captures everything.
# so that Docker gets its exit signal from the primary process.
set -e set -e
echo "Starting FastAPI backend on :8000 ..." echo "[start.sh] Starting FastAPI backend on :8000 ..."
uvicorn web.app:app --host 127.0.0.1 --port 8000 --workers 1 & uvicorn web.app:app --host 127.0.0.1 --port 8000 --workers 1 2>&1 &
UVICORN_PID=$! UVICORN_PID=$!
echo "Starting Next.js frontend on :3000 ..." # Give uvicorn a moment to start (or crash)
exec node server.js sleep 2
if ! kill -0 $UVICORN_PID 2>/dev/null; then
echo "[start.sh] ERROR: uvicorn failed to start!"
# Don't exit — let Node.js run so the UI is accessible for debugging
fi
echo "[start.sh] Starting Next.js frontend on :3000 ..."
node server.js