| # Function to handle shutdown signals | |
| cleanup() { | |
| echo "Shutting down services..." | |
| kill $FRONTEND_PID $BACKEND_PID 2>/dev/null | |
| wait | |
| exit 0 | |
| } | |
| # Set up signal handlers | |
| trap cleanup SIGTERM SIGINT | |
| # Start Next.js frontend in the background on port 7860 | |
| echo "Starting LumaKit Frontend on port 7860..." | |
| cd /app/frontend && PORT=7860 bunx next start & | |
| FRONTEND_PID=$! | |
| echo "Frontend started with PID: $FRONTEND_PID" | |
| # Wait a moment for frontend to initialize | |
| sleep 2 | |
| # Start the Express backend on port 5000 | |
| echo "Starting LumaKit Backend on port 5000..." | |
| cd /app && PORT=5000 bun run src/index.js & | |
| BACKEND_PID=$! | |
| echo "Backend started with PID: $BACKEND_PID" | |
| # Display service information | |
| echo "================================" | |
| echo "LumaKit Services Running:" | |
| echo "Frontend (Next.js): http://localhost:7860" | |
| echo "Backend (Express): http://localhost:5000" | |
| echo "Backend Stats: http://localhost:5000/stats" | |
| echo "================================" | |
| # Wait for any process to exit | |
| wait -n | |
| # If we reach here, one of the processes has exited | |
| echo "One of the services has stopped. Shutting down..." | |
| cleanup |