diff --git a/start-dev.sh b/start-dev.sh index be6cb6b..f2e0e0c 100755 --- a/start-dev.sh +++ b/start-dev.sh @@ -124,7 +124,7 @@ if [ ! -d "node_modules" ]; then fi # Start backend in background -HOST=0.0.0.0 PORT=3020 API_PORT=3020 npm run start:dev > /tmp/backend-dev.log 2>&1 & +npm run start:dev > /tmp/backend-dev.log 2>&1 & BACKEND_PID=$! echo $BACKEND_PID > /tmp/backend-dev.pid success "Backend API started (PID: $BACKEND_PID)" @@ -152,8 +152,8 @@ EOF log "Created .env.local for frontend" fi -# Start frontend in background (override the port in package.json) -npx next dev -p 3030 -H 0.0.0.0 > /tmp/frontend-dev.log 2>&1 & +# Start frontend in background using full path to next +node_modules/next/dist/bin/next dev -p 3030 -H 0.0.0.0 > /tmp/frontend-dev.log 2>&1 & FRONTEND_PID=$! echo $FRONTEND_PID > /tmp/frontend-dev.pid success "Frontend started (PID: $FRONTEND_PID)" @@ -179,8 +179,8 @@ EOF log "Created .env.local for admin dashboard" fi -# Start admin dashboard in background (use npx to ensure correct port) -npx next dev -p 3335 -H 0.0.0.0 > /tmp/admin-dev.log 2>&1 & +# Start admin dashboard in background using full path to next +node_modules/next/dist/bin/next dev -p 3335 -H 0.0.0.0 > /tmp/admin-dev.log 2>&1 & ADMIN_PID=$! echo $ADMIN_PID > /tmp/admin-dev.pid success "Admin Dashboard started (PID: $ADMIN_PID)" @@ -188,25 +188,33 @@ log "Admin accessible at: http://pfadmin.noru1.ro (0.0.0.0:3335)" # Step 4: Verify all services are running log "${CYAN}Step 4: Verifying services...${NC}" -sleep 5 +log "Waiting 30 seconds for services to start..." +sleep 30 verify_service() { local SERVICE=$1 local PORT=$2 local PID_FILE=$3 - if [ -f "$PID_FILE" ]; then - PID=$(cat $PID_FILE) - if kill -0 $PID 2>/dev/null; then - success "$SERVICE is running (PID: $PID)" - return 0 + # Check if port is listening + if ss -tulpn | grep -q ":$PORT.*LISTEN"; then + success "$SERVICE is listening on port $PORT" + return 0 + else + # Check if process is still starting + if [ -f "$PID_FILE" ]; then + PID=$(cat $PID_FILE) + if kill -0 $PID 2>/dev/null; then + warning "$SERVICE is running (PID: $PID) but not yet listening on port $PORT" + return 1 + else + error "$SERVICE process (PID: $PID) died. Check logs: tail -50 /tmp/${SERVICE,,}-dev.log" + return 1 + fi else - warning "$SERVICE process died" + warning "$SERVICE PID file not found" return 1 fi - else - warning "$SERVICE PID file not found" - return 1 fi }