REST API Reference
PMDaemon provides a comprehensive REST API for remote process management and monitoring. The API is PM2-compatible and includes additional features unique to PMDaemon.
Getting Started
Start the Web Server
# Start with default settings (localhost:9615)
pmdaemon web
# Custom host and port
pmdaemon web --host 0.0.0.0 --port 8080
# With API key authentication (recommended for production)
pmdaemon web --api-key "your-secret-api-key"
Base URL
http://localhost:9615
Authentication
PMDaemon API supports optional API key authentication for security:
# Start with API key authentication
pmdaemon web --api-key "your-secret-api-key"
Using API Authentication
When an API key is configured, all API endpoints (except root /
and WebSocket /ws
) require authentication.
Authorization Header (Bearer Token):
curl -H "Authorization: Bearer your-secret-api-key" \
http://localhost:9615/api/processes
X-API-Key Header:
curl -H "X-API-Key: your-secret-api-key" \
http://localhost:9615/api/processes
ApiKey Header:
curl -H "Authorization: ApiKey your-secret-api-key" \
http://localhost:9615/api/processes
Security Recommendations
For production deployments:
- Always use API key authentication (
--api-key
) - Run behind a reverse proxy with HTTPS
- Use firewall rules to restrict access
- Bind to localhost only (
--host 127.0.0.1
) if not using a reverse proxy
API Endpoints
Root Endpoint
GET /
Get API information and available endpoints.
Response
{
"name": "PMDaemon",
"version": "0.1.1",
"description": "A feature-rich PM2 clone in Rust with advanced capabilities",
"status": "running",
"endpoints": {
"processes": "/api/processes",
"system": "/api/system",
"status": "/api/status",
"websocket": "/ws"
}
}
Process Management
List Processes
GET /api/processes
Get list of all processes with their current status.
Query Parameters
Parameter | Type | Description | Example |
---|---|---|---|
status | String | Filter by process status | ?status=online |
name | String | Filter by process name | ?name=web-app |
Response
[
{
"id": 0,
"name": "web-app",
"status": "online",
"pid": 1234,
"port": "3000",
"cpu_usage": 2.5,
"memory_usage": 47448064,
"uptime": "2h 15m 30s",
"restarts": 0,
"health_status": "healthy"
},
{
"id": 1,
"name": "api-server",
"status": "online",
"pid": 1235,
"port": "8000",
"cpu_usage": 1.8,
"memory_usage": 33554432,
"uptime": "1h 45m 12s",
"restarts": 1,
"health_status": "healthy"
}
]
Get Process Details
GET /api/processes/{id}
Get detailed information about a specific process.
Path Parameters
Parameter | Type | Description |
---|---|---|
id | String | Process ID or name |
Response
{
"id": 0,
"name": "web-app",
"status": "online",
"pid": 1234,
"port": "3000",
"cpu_usage": 2.5,
"memory_usage": 47448064,
"uptime": "2h 15m 30s",
"restarts": 0,
"config": {
"script": "node",
"args": ["server.js"],
"instances": 1,
"max_memory_restart": 536870912,
"port": "3000",
"env": {
"NODE_ENV": "production",
"PORT": "3000"
}
},
"health_check": {
"enabled": true,
"check_type": "http",
"url": "http://localhost:3000/health",
"status": "healthy",
"last_check": "2024-01-15T10:30:00Z",
"response_time": 45
},
"logs": {
"out_file": "/home/user/.local/share/pmdaemon/logs/web-app-0.out",
"error_file": "/home/user/.local/share/pmdaemon/logs/web-app-0.err"
}
}
Process Management
Note: PMDaemon API only allows management of existing processes for security reasons. New processes must be created via the CLI:
# Create processes via CLI
pmdaemon start "node server.js" --name "my-app"
# Then manage via API
curl -H "X-API-Key: your-key" http://localhost:9615/api/processes
Stop Process
POST /api/processes/{id}/stop
Stop a running process.