start-dev.sh
Starts both backend and frontend in development mode with monitoring, logging, and health checks.
Purpose
The all-in-one development script that manages both services, monitors their health, and provides centralized logging.
Location
Must be run from the scripts/ directory:
cd scripts
./start-dev.sh
What It Does
- Stops existing services - Cleans up any running instances
- Validates setup - Checks that both backend and frontend are configured
- Starts backend - Launches Node.js server on port 3000
- Waits for backend - Polls health endpoint until ready
- Starts frontend - Launches Flutter app for your platform
- Monitors processes - Watches both services and restarts on failure
- Handles shutdown - Cleanly stops both on Ctrl+C
Prerequisites
- Backend setup completed (
./setup-backend.sh) - Frontend setup completed (
./setup-frontend.sh) - Valid
backend/.envwith OpenAI API key
Output
Backend started (PID: 12345)
Logs: logs/backend.log
API: http://localhost:3000
✓ Backend is ready
Frontend started (PID: 12346)
Logs: logs/frontend.log
Platform: linux
Development Environment Running!
Backend: http://localhost:3000
Frontend: Running on linux
Logs:
tail -f logs/backend.log
tail -f logs/frontend.log
Press Ctrl+C to stop both services
Logs
All output is captured in:
logs/backend.log- Backend server logslogs/frontend.log- Flutter app logs
View in real-time:
# Backend
tail -f logs/backend.log
# Frontend
tail -f logs/frontend.log
# Both
tail -f logs/backend.log logs/frontend.log
Process Management
The script creates PID files:
/tmp/ai-repurposer-backend.pid/tmp/ai-repurposer-frontend.pid
This allows the script to:
- Detect and stop existing processes
- Monitor for crashes
- Clean up on exit
Platform Detection
Auto-detects your platform:
- Linux
- macOS
- Windows
Health Checks
Before starting the frontend, the script:
- Waits for backend to respond at
http://localhost:3000/health - Retries up to 15 times (30 seconds total)
- Exits with error if backend doesn't respond
Stopping Services
Press Ctrl+C to stop both services cleanly.
The script will:
- Kill backend process
- Kill frontend process
- Remove PID files
- Exit gracefully
Troubleshooting
Backend fails to start
Check logs:
cat logs/backend.log
Common issues:
- Port 3000 already in use
- Invalid
.envconfiguration - Missing OpenAI API key
Frontend fails to start
Check logs:
cat logs/frontend.log
Common issues:
- Backend not running
- Flutter not configured
- Platform support not enabled
Port already in use
Kill existing process:
lsof -ti:3000 | xargs kill
Or change port in backend/.env:
PORT=3001
Source Code
Located at: scripts/start-dev.sh
Key features:
- Background process management
- Automatic health checks
- Centralized logging
- Graceful shutdown
- Process monitoring and restart
- Platform-aware frontend launching