fix: Update start-dev.sh to use correct paths and better verification
Some checks failed
ParentFlow CI/CD Pipeline / Backend Tests (push) Has been cancelled
ParentFlow CI/CD Pipeline / Frontend Tests (push) Has been cancelled
ParentFlow CI/CD Pipeline / Security Scanning (push) Has been cancelled
ParentFlow CI/CD Pipeline / Build Docker Images (map[context:maternal-app/maternal-app-backend dockerfile:Dockerfile.production name:backend]) (push) Has been cancelled
ParentFlow CI/CD Pipeline / Build Docker Images (map[context:maternal-web dockerfile:Dockerfile.production name:frontend]) (push) Has been cancelled
ParentFlow CI/CD Pipeline / Deploy to Development (push) Has been cancelled
ParentFlow CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / Lint and Test (push) Has been cancelled
CI/CD Pipeline / E2E Tests (push) Has been cancelled
CI/CD Pipeline / Build Application (push) Has been cancelled

- Use node_modules/next/dist/bin/next instead of npx for frontend and admin
- Backend uses npm run start:dev directly (no HOST/PORT env vars needed)
- Increase verification wait time to 30 seconds
- Check actual port listening status with ss command instead of just PID
- Provide better error messages with log file paths
This commit is contained in:
Andrei
2025-10-07 07:18:38 +00:00
parent cec6ceb97e
commit 6940a53b3d

View File

@@ -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,26 +188,34 @@ 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
# 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
success "$SERVICE is running (PID: $PID)"
return 0
warning "$SERVICE is running (PID: $PID) but not yet listening on port $PORT"
return 1
else
warning "$SERVICE process died"
error "$SERVICE process (PID: $PID) died. Check logs: tail -50 /tmp/${SERVICE,,}-dev.log"
return 1
fi
else
warning "$SERVICE PID file not found"
return 1
fi
fi
}
ALL_GOOD=true