Harden dev service daemon startup

This commit is contained in:
taohe
2026-06-10 21:41:40 +08:00
parent b66152c514
commit 582bfda6f8
+7 -4
View File
@@ -495,11 +495,14 @@ run_service() {
echo "Starting $name..." echo "Starting $name..."
if $DAEMON_MODE; then if $DAEMON_MODE; then
nohup sh -c "$cmd" > /dev/null 2>&1 & nohup sh -c "$cmd" < /dev/null > /dev/null 2>&1 &
else else
sh -c "$cmd" & sh -c "$cmd" &
fi fi
service_pid=$! service_pid=$!
if $DAEMON_MODE; then
disown "$service_pid" 2>/dev/null || true
fi
./scripts/wait-for-port.sh "$port" "$timeout" "$name" || { ./scripts/wait-for-port.sh "$port" "$timeout" "$name" || {
local logfile="logs/$(echo "$name" | tr '[:upper:]' '[:lower:]' | tr ' ' '-').log" local logfile="logs/$(echo "$name" | tr '[:upper:]' '[:lower:]' | tr ' ' '-').log"
@@ -523,17 +526,17 @@ mkdir -p temp/client_body_temp temp/proxy_temp temp/fastcgi_temp temp/uwsgi_temp
# 1. Gateway API # 1. Gateway API
run_service "Gateway" \ run_service "Gateway" \
"cd backend && PYTHONPATH=. uv run uvicorn app.gateway.app:app --host 0.0.0.0 --port 8001 $GATEWAY_EXTRA_FLAGS > ../logs/gateway.log 2>&1" \ "cd backend && exec env PYTHONPATH=. uv run uvicorn app.gateway.app:app --host 0.0.0.0 --port 8001 $GATEWAY_EXTRA_FLAGS > ../logs/gateway.log 2>&1" \
8001 30 8001 30
# 2. Frontend # 2. Frontend
run_service "Frontend" \ run_service "Frontend" \
"cd frontend && $FRONTEND_CMD > ../logs/frontend.log 2>&1" \ "cd frontend && exec $FRONTEND_CMD > ../logs/frontend.log 2>&1" \
3000 120 3000 120
# 3. Nginx # 3. Nginx
run_service "Nginx" \ run_service "Nginx" \
"nginx -g 'daemon off;' -c '$REPO_ROOT/docker/nginx/nginx.local.conf' -p '$REPO_ROOT' > logs/nginx.log 2>&1" \ "exec nginx -g 'daemon off;' -c '$REPO_ROOT/docker/nginx/nginx.local.conf' -p '$REPO_ROOT' > logs/nginx.log 2>&1" \
2026 10 2026 10
# ── Ready ──────────────────────────────────────────────────────────────────── # ── Ready ────────────────────────────────────────────────────────────────────