A shell script utility for managing local development servers. Provides simple commands to start, stop, restart, and monitor multiple development servers with logging and process management.
Add this line to your ~/.zshrc or ~/.bash_profile:
export PATH="$PATH:/Users/stian/dev/scripts/dev-control"Then reload your shell:
source ~/.zshrc # or source ~/.bash_profileFor convenient project-specific aliases, add this to your ~/.zshrc or ~/.bash_profile:
source /Users/stian/dev/scripts/dev-control/.dev-aliasesThen reload your shell:
source ~/.zshrc # or source ~/.bash_profileOnce installed in PATH, you can run the script globally:
dev-start.sh [command]Or if aliases are enabled:
sp [command]
sp-start
sp-stop
sp-status
sp-restart
sp-logs| Command | Description |
|---|---|
start |
Start both backend and frontend servers |
stop |
Stop both servers |
status |
Display detailed status of both servers (PID, ports, CPU, memory, URLs) |
restart |
Restart both servers (stop + start) |
logs |
Tail logs from both servers in real-time |
# Start servers
dev-start.sh start
# Check status
dev-start.sh status
# View live logs
dev-start.sh logs
# Restart servers
dev-start.sh restart
# Stop servers
dev-start.sh stopThe script is project-agnostic and works with any project structure:
- Project Root: Uses the directory where you run the script from (
pwd) - Backend Port: Defaults to 3001 (can be overridden with
BACKEND_PORT=3002) - Frontend Port: Defaults to 3000 (can be overridden with
FRONTEND_PORT=3001) - Log Directory: Creates
.dev-logs/in the project root - PID Files: Stored in
/tmp/using project folder name for uniqueness
Simply navigate to your project root and run:
cd /path/to/your/project
dev-start.sh startOverride default ports by setting environment variables:
BACKEND_PORT=3002 FRONTEND_PORT=3001 dev-start.sh startYou can run multiple projects simultaneously. Each uses its own PID files based on the folder name:
# Project 1
cd /path/to/project1
dev-start.sh start
# Project 2 (in another terminal)
cd /path/to/project2
dev-start.sh start- Dual Server Management: Control backend and frontend servers simultaneously
- Process Tracking: Uses PID files to track running processes
- Resource Monitoring: Displays CPU and memory usage in status view
- Comprehensive Logging: Writes separate logs for backend and frontend
- Color-Coded Output: Easy-to-read colored terminal output
- Process Safety: Checks if processes are actually running before operations
- Real-time Log Tailing: View both backend and frontend logs simultaneously
Logs are stored in the project's .dev-logs/ directory:
- Backend:
.dev-logs/backend.log - Frontend:
.dev-logs/frontend.log
View logs manually:
tail -f /Users/stian/dev/splan.no/sp-utlegg2/.dev-logs/backend.log
tail -f /Users/stian/dev/splan.no/sp-utlegg2/.dev-logs/frontend.logIf you source .dev-aliases, you get these shortcuts:
sp-start # Start servers
sp-stop # Stop servers
sp-status # Check status
sp-restart # Restart servers
sp-logs # View logs
sp-cd # Go to project root
sp-frontend # Go to frontend directory
sp-backend # Go to backend directory
sp-build # Build both backend and frontend
sp-test # Run tests
sp [command] # Generic sp command-
Check if ports are already in use:
lsof -i :3000 # Frontend lsof -i :3001 # Backend
-
Review the logs:
tail -f .dev-logs/backend.log tail -f .dev-logs/frontend.log
If you see "already running" but servers aren't actually running, clean up:
rm /tmp/sp-utlegg2-backend.pid /tmp/sp-utlegg2-frontend.pidThe logs command uses named pipes. If it hangs, kill it and try again:
dev-start.sh stop
rm /tmp/backend_pipe /tmp/frontend_pipe 2>/dev/null
dev-start.sh logs- bash 4.0+
- npm (for running dev servers)
- Standard Unix utilities (ps, kill, mkdir, cat, sed)
dev-start.sh- Main control script.dev-aliases- Optional shell aliases for convenienceREADME.md- This documentation
Internal utility script for splan.no development