#!/bin/bash # Start Production Servers Script # Ports: Backend 3020, Frontend 3030 echo "Starting ParentFlow Production Servers..." # Kill any existing processes on the ports echo "Cleaning up existing processes..." lsof -ti:3020 | xargs kill -9 2>/dev/null lsof -ti:3030 | xargs kill -9 2>/dev/null sleep 2 # Start Backend on port 3020 echo "Starting backend on port 3020..." cd /root/maternal-app/maternal-app/maternal-app-backend PORT=3020 API_PORT=3020 NODE_ENV=production nohup node dist/main.js > /root/maternal-app/logs/backend-prod.log 2>&1 & BACKEND_PID=$! echo "Backend started with PID: $BACKEND_PID" # Start Frontend on port 3030 echo "Starting frontend on port 3030..." cd /root/maternal-app/maternal-web PORT=3030 NODE_ENV=production nohup npm run start > /root/maternal-app/logs/frontend-prod.log 2>&1 & FRONTEND_PID=$! echo "Frontend started with PID: $FRONTEND_PID" # Wait a moment for servers to start sleep 5 # Check if servers are running echo "" echo "Checking server status..." if lsof -i:3020 > /dev/null 2>&1; then echo "✅ Backend is running on port 3020" else echo "❌ Backend failed to start on port 3020" fi if lsof -i:3030 > /dev/null 2>&1; then echo "✅ Frontend is running on port 3030" else echo "❌ Frontend failed to start on port 3030" fi echo "" echo "Production servers started!" echo "Backend: http://localhost:3020" echo "Frontend: http://localhost:3030" echo "" echo "To check logs:" echo " Backend: tail -f /root/maternal-app/logs/backend-prod.log" echo " Frontend: tail -f /root/maternal-app/logs/frontend-prod.log"