From aef38e871fecb0aa9993357a5f930e69090b3100 Mon Sep 17 00:00:00 2001 From: Daniel Bedeleanu Date: Wed, 22 Apr 2026 18:35:53 +0300 Subject: [PATCH] fix(6): ensure background processes run from correct directories - Wrap backend uvicorn with proper working directory subshell - Wrap frontend Next.js server with proper working directory subshell - Use subshell syntax (cd && run) to ensure processes inherit correct context - Fixes processes starting but immediately crashing --- start_server.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/start_server.sh b/start_server.sh index 1df72106..90bc9a30 100755 --- a/start_server.sh +++ b/start_server.sh @@ -128,9 +128,9 @@ if [[ ! -f "../$DATA_DIR/inventory.db" ]]; then python3 -c "from db_manager import init_db; init_db()" || true fi -# Start uvicorn in background +# Start uvicorn in background (with proper working directory) log_info " Starting uvicorn server..." -python3 -m uvicorn main:app --host 0.0.0.0 --port "$BACKEND_PORT" --log-level "${LOG_LEVEL,,}" >> "$BACKEND_LOG" 2>&1 & +(cd "$(pwd)" && python3 -m uvicorn main:app --host 0.0.0.0 --port "$BACKEND_PORT" --log-level "${LOG_LEVEL,,}" >> "$BACKEND_LOG" 2>&1) & BACKEND_PID=$! log_success " ✓ Backend started (PID: $BACKEND_PID, Port: $BACKEND_PORT)" @@ -163,9 +163,10 @@ if [[ ! -d ".next" ]]; then npm run build || log_error "Failed to build frontend" fi -# Start Next.js in production mode +# Start Next.js in production mode (with proper working directory) log_info " Starting Next.js server..." -PORT="$FRONTEND_PORT" node .next/standalone/server.js >> "$FRONTEND_LOG" 2>&1 & +FRONTEND_DIR="$(pwd)" +(cd "$FRONTEND_DIR" && PORT="$FRONTEND_PORT" node .next/standalone/server.js >> "$FRONTEND_LOG" 2>&1) & FRONTEND_PID=$! log_success " ✓ Frontend started (PID: $FRONTEND_PID, Port: $FRONTEND_PORT)"