A high-performance process manager built in Rust, inspired by PM2 with innovative features that exceed the original. PMDaemon is designed for modern application deployment with advanced port management, real-time monitoring, and production-ready web APIs.
- Key Features
- Installation
- Quick Start
- Command Reference
- Configuration Options
- Web API
- Monitoring
- Comparison with PM2
- Library Usage
- Testing
- Roadmap
- Contributing
- License
- Process Lifecycle - Start, stop, restart, reload, and delete operations
- Clustering - Run multiple instances with automatic load balancing
- Auto-restart - Automatic restart on crashes with configurable limits
- Signal Handling - Graceful shutdown with SIGTERM/SIGINT and custom signals
- Configuration Persistence - Process configs saved and restored between sessions
- Real-time Monitoring - CPU, memory, uptime tracking with system metrics
- Memory Limit Enforcement - Automatic restart when processes exceed memory limits
- Process Health Checks - Continuous monitoring with automatic failure detection
- Log Management - Separate stdout/stderr files with viewing and following
- Port Range Distribution - Automatically distribute consecutive ports to cluster instances
- Auto-assignment - Find first available port in specified range
- Conflict Detection - Prevent port conflicts at the process manager level
- Runtime Port Overrides - Change ports during restart without modifying saved config
- Port Visibility - Display assigned ports in process listings
- REST API - Full process management via HTTP with PM2-compatible responses
- WebSocket Support - Live process status and system metrics streaming
- Production Web Server - Built on Axum with CORS and security headers
git clone https://github.com/entrepeneur4lyf/pmdaemon
cd pmdaemon
cargo build --release
sudo cp target/release/pmdaemon /usr/local/bin/
cargo install pmdaemon
# Start a process
pmdaemon start app.js --name myapp
# List all processes
pmdaemon list
# Stop a process
pmdaemon stop myapp
# Restart a process
pmdaemon restart myapp
# Delete a process
pmdaemon delete myapp
# Start 4 instances with port range
pmdaemon start server.js --instances 4 --port 4000-4003
# Auto-assign ports from range
pmdaemon start worker.js --port auto:5000-5100
# Runtime port override (doesn't modify saved config)
pmdaemon restart myapp --port 3001
# Set memory limit with auto-restart
pmdaemon start app.js --max-memory 100M
# Real-time monitoring
pmdaemon monit
# View logs
pmdaemon logs myapp
# Start web API server for remote monitoring
pmdaemon web --port 9615 --host 127.0.0.1
Command | Description | Example |
---|---|---|
start |
Start a new process | pmdaemon start app.js --name myapp |
stop |
Stop a process | pmdaemon stop myapp |
restart |
Restart a process | pmdaemon restart myapp |
reload |
Graceful restart | pmdaemon reload myapp |
delete |
Delete a process | pmdaemon delete myapp |
list |
List all processes | pmdaemon list |
monit |
Real-time monitoring | pmdaemon monit |
logs |
View process logs | pmdaemon logs myapp |
info |
Process details | pmdaemon info myapp |
web |
Start web API server | pmdaemon web --port 9615 |
pmdaemon start app.js \
--name "my-app" \
--instances 4 \
--port 3000-3003 \
--max-memory 512M \
--env NODE_ENV=production \
--cwd /path/to/app \
--log-file /var/log/app.log
Option | Description | Example |
---|---|---|
--port 3000 |
Single port assignment | Assigns port 3000 |
--port 3000-3005 |
Port range for clusters | Distributes 3000-3005 |
--port auto:4000-4100 |
Auto-find available port | First available in range |
PMDaemon provides a comprehensive REST API compatible with PM2:
Method | Endpoint | Description |
---|---|---|
GET |
/api/processes |
List all processes |
POST |
/api/processes |
Start a new process |
DELETE |
/api/processes/:id |
Stop/delete a process |
GET |
/api/system |
System metrics |
GET |
/api/logs/:id |
Process logs |
WS |
/ws |
Real-time updates |
# List processes
curl http://localhost:9615/api/processes
# Start a process
curl -X POST http://localhost:9615/api/processes \
-H "Content-Type: application/json" \
-d '{"name": "api-server", "script": "node", "args": ["server.js"]}'
# WebSocket for real-time updates
wscat -c ws://localhost:9615/ws
PMDaemon provides comprehensive monitoring capabilities:
- CPU usage percentage
- Memory usage (RSS)
- Process uptime
- Restart count
- Port assignments
- Process state
- Separate stdout/stderr files
- Automatic log rotation
- Real-time log following
- HTTP log access via API
Feature | PMDaemon | PM2 |
---|---|---|
Port range distribution | โ | โ |
Auto port assignment | โ | โ |
Runtime port override | โ | โ |
Built-in port conflict detection | โ | โ |
Memory limit enforcement | โ | โ |
WebSocket real-time updates | โ | โ |
Rust performance | โ | โ |
PM2-compatible API | โ | โ |
PMDaemon can also be used as a Rust library:
use pmdaemon::{ProcessManager, ProcessConfig, config::PortConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut manager = ProcessManager::new().await?;
let config = ProcessConfig::builder()
.name("web-cluster")
.script("node")
.args(vec!["app.js"])
.instances(4)
.port(PortConfig::Range(3000, 3003))
.max_memory_restart(512 * 1024 * 1024) // 512MB
.build()?;
manager.start(config).await?;
println!("Started 4-instance cluster on ports 3000-3003");
Ok(())
}
PMDaemon has comprehensive test coverage:
# Run all tests
cargo test
# Run with coverage
cargo test --all-features
# Run documentation tests
cargo test --doc
# Run integration tests
cargo test --test integration_tests
# Run end-to-end tests
cargo test --test e2e_tests
- 158 Total Tests
- 120 Unit tests
- 11 Integration tests
- 8 End-to-end tests
- 19 Documentation tests
- โ Core process management (Phase 1-3)
- โ CLI interface with all PM2-compatible commands (Phase 5)
- โ Advanced monitoring and logging (Phase 6)
- โ Web API and WebSocket support (Phase 7)
- โ Comprehensive test suite (Phase 9.1-9.3)
- ๐ API documentation beyond docs.rs
- ๐ Changelog and versioning strategy
- ๐ Release process documentation
- ๐จ v2.0 - Enhanced CLI with ratatui for interactive terminal UI
- ๐ Advanced metrics visualization
- ๐ Plugin system for custom monitors
- ๐ Distributed process management
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
- Follow Rust best practices and idioms
- Add tests for new features
- Update documentation as needed
- Ensure all tests pass before submitting PR
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by PM2 - The original Node.js process manager
- Built with Rust for performance and safety
- Uses Tokio for async runtime
- Web server powered by Axum
PMDaemon - Process management, evolved. ๐