|
4 | 4 | <p style="margin: 5px 0 0; color: #cccccc;">A high-performance, cross-platform process manager built in Rust</p> |
5 | 5 | </div> |
6 | 6 |
|
7 | | -[](https://www.rust-lang.org) |
8 | | -[](https://opensource.org/licenses/MIT) |
9 | | -[]() |
10 | | -[]() |
| 7 | +[](https://github.com/entrepeneur4lyf/pmdaemon/stargazers) |
| 8 | +[](https://crates.io/crates/pmdaemon) |
| 9 | +[](https://crates.io/crates/pmdaemon) |
| 10 | +[](LICENSE-MIT) |
| 11 | +[](https://github.com/entrepeneur4lyf/pmdaemon/actions/workflows/ci.yml?query=branch%3Amain) |
| 12 | +[](https://www.rust-lang.org) |
| 13 | +[](https://github.com/entrepeneur4lyf/pmdaemon) |
11 | 14 |
|
12 | 15 | A high-performance, **cross-platform** process manager built in Rust, inspired by PM2 with innovative features that exceed the original. PMDaemon runs natively on **Linux, Windows, and macOS** and is designed for modern application deployment with advanced port management, real-time monitoring, and production-ready web APIs. |
13 | 16 |
|
@@ -193,8 +196,11 @@ pmdaemon start api.js --health-check-url http://localhost:9615/status --wait-tim |
193 | 196 |
|
194 | 197 | ### Web API Server |
195 | 198 | ```bash |
196 | | -# Start web API server for remote monitoring |
| 199 | +# Start web API server for remote monitoring (no authentication) |
197 | 200 | pmdaemon web --port 9615 --host 127.0.0.1 |
| 201 | + |
| 202 | +# Start with API key authentication (recommended for production) |
| 203 | +pmdaemon web --api-key "your-secret-api-key" |
198 | 204 | ``` |
199 | 205 |
|
200 | 206 | ## 📋 Command Reference |
@@ -321,28 +327,37 @@ pmdaemon start app.js \ |
321 | 327 |
|
322 | 328 | ## 🌐 Web API |
323 | 329 |
|
324 | | -PMDaemon provides a comprehensive REST API compatible with PM2: |
| 330 | +PMDaemon provides a comprehensive REST API with optional authentication: |
| 331 | + |
| 332 | +### Security Features |
| 333 | +- **API Key Authentication** - Secure your API with keys |
| 334 | +- **Process Management Only** - Cannot create new processes for security |
| 335 | +- **Production Ready** - Built with security best practices |
325 | 336 |
|
326 | 337 | ### Endpoints |
327 | 338 |
|
328 | | -| Method | Endpoint | Description | |
329 | | -|----------|----------------------------|------------------------------| |
330 | | -| `GET` | `/api/processes` | List all processes | |
331 | | -| `POST` | `/api/processes` | Start a new process | |
332 | | -| `DELETE` | `/api/processes/:id` | Stop/delete a process | |
333 | | -| `GET` | `/api/system` | System metrics | |
334 | | -| `GET` | `/api/logs/:id` | Process logs | |
335 | | -| `WS` | `/ws` | Real-time updates | |
| 339 | +| Method | Endpoint | Description | Auth Required | |
| 340 | +|----------|----------------------------|------------------------------|---------------| |
| 341 | +| `GET` | `/api/processes` | List all processes | ✅ | |
| 342 | +| `POST` | `/api/processes/:id/start` | Start existing process | ✅ | |
| 343 | +| `DELETE` | `/api/processes/:id` | Stop/delete a process | ✅ | |
| 344 | +| `GET` | `/api/system` | System metrics | ✅ | |
| 345 | +| `GET` | `/api/logs/:id` | Process logs | ✅ | |
| 346 | +| `WS` | `/ws` | Real-time updates | ❌ | |
336 | 347 |
|
337 | 348 | ### Example API Usage |
338 | 349 | ```bash |
339 | | -# List processes |
340 | | -curl http://localhost:9615/api/processes |
| 350 | +# Start with authentication |
| 351 | +pmdaemon web --api-key "your-secret-key" |
341 | 352 |
|
342 | | -# Start a process |
343 | | -curl -X POST http://localhost:9615/api/processes \ |
344 | | - -H "Content-Type: application/json" \ |
345 | | - -d '{"name": "api-server", "script": "node", "args": ["server.js"]}' |
| 353 | +# List processes (with API key) |
| 354 | +curl -H "Authorization: Bearer your-secret-key" \ |
| 355 | + http://localhost:9615/api/processes |
| 356 | + |
| 357 | +# Start an existing process (processes created via CLI only) |
| 358 | +curl -X POST \ |
| 359 | + -H "Authorization: Bearer your-secret-key" \ |
| 360 | + http://localhost:9615/api/processes/my-app/start |
346 | 361 |
|
347 | 362 | # WebSocket for real-time updates |
348 | 363 | wscat -c ws://localhost:9615/ws |
@@ -406,33 +421,70 @@ PMDaemon provides comprehensive monitoring capabilities: |
406 | 421 | ```mermaid |
407 | 422 | graph TD |
408 | 423 |
|
409 | | - 17017["User<br>External Actor"] |
410 | | - subgraph 17008["PMDaemon Application<br>Rust"] |
411 | | - 17009["CLI Entry Point<br>Rust"] |
412 | | - 17010["Web API & UI<br>Rust / HTTP"] |
413 | | - 17011["Core Process Orchestrator<br>Rust"] |
414 | | - 17012["Process Execution & State<br>Rust"] |
415 | | - 17013["Configuration Service<br>Rust"] |
416 | | - 17014["Process Health Monitor<br>Rust"] |
417 | | - 17015["Metrics & Monitoring<br>Rust"] |
418 | | - 17016["OS Signal Handler<br>Rust"] |
419 | | - %% Edges at this level (grouped by source) |
420 | | - 17009["CLI Entry Point<br>Rust"] -->|Executes commands via| 17011["Core Process Orchestrator<br>Rust"] |
421 | | - 17010["Web API & UI<br>Rust / HTTP"] -->|Manages processes via| 17011["Core Process Orchestrator<br>Rust"] |
422 | | - 17010["Web API & UI<br>Rust / HTTP"] -->|Gets status from| 17015["Metrics & Monitoring<br>Rust"] |
423 | | - 17016["OS Signal Handler<br>Rust"] -->|Notifies of OS signals| 17011["Core Process Orchestrator<br>Rust"] |
424 | | - 17011["Core Process Orchestrator<br>Rust"] -->|Controls & Monitors| 17012["Process Execution & State<br>Rust"] |
425 | | - 17011["Core Process Orchestrator<br>Rust"] -->|Loads/Saves config| 17013["Configuration Service<br>Rust"] |
426 | | - 17011["Core Process Orchestrator<br>Rust"] -->|Manages| 17014["Process Health Monitor<br>Rust"] |
427 | | - 17011["Core Process Orchestrator<br>Rust"] -->|Updates/Gets metrics from| 17015["Metrics & Monitoring<br>Rust"] |
428 | | - 17011["Core Process Orchestrator<br>Rust"] -->|Initializes| 17016["OS Signal Handler<br>Rust"] |
429 | | - 17014["Process Health Monitor<br>Rust"] -->|Checks status of| 17012["Process Execution & State<br>Rust"] |
430 | | - 17015["Metrics & Monitoring<br>Rust"] -->|Collects metrics from| 17012["Process Execution & State<br>Rust"] |
431 | | - 17012["Process Execution & State<br>Rust"] -->|Uses config from| 17013["Configuration Service<br>Rust"] |
| 424 | + User["User<br>External Actor"] |
| 425 | + subgraph PMDaemon["PMDaemon Application<br>Rust"] |
| 426 | + CLI["CLI Entry Point<br>Rust"] |
| 427 | +
|
| 428 | + subgraph WebLayer["Web Layer"] |
| 429 | + WebAPI["Web API Server<br>Axum / HTTP"] |
| 430 | + Auth["API Key Authentication<br>Middleware"] |
| 431 | + WebSocket["WebSocket Handler<br>Real-time Updates"] |
| 432 | + end |
| 433 | +
|
| 434 | + subgraph CoreLayer["Core Management Layer"] |
| 435 | + ProcessManager["Process Manager<br>Core Orchestrator"] |
| 436 | + PortManager["Port Manager<br>Allocation & Conflicts"] |
| 437 | + ConfigService["Configuration Service<br>JSON/YAML/TOML"] |
| 438 | + end |
| 439 | +
|
| 440 | + subgraph MonitoringLayer["Monitoring & Health Layer"] |
| 441 | + HealthMonitor["Health Monitor<br>HTTP & Script Checks"] |
| 442 | + SystemMonitor["System Monitor<br>CPU/Memory/Load"] |
| 443 | + ProcessMonitor["Process Monitor<br>Individual Process Metrics"] |
| 444 | + end |
| 445 | +
|
| 446 | + subgraph ProcessLayer["Process Execution Layer"] |
| 447 | + ProcessExecution["Process Execution<br>Spawn & Control"] |
| 448 | + SignalHandler["Signal Handler<br>OS Signal Management"] |
| 449 | + LogManager["Log Manager<br>stdout/stderr Capture"] |
| 450 | + end |
| 451 | +
|
| 452 | + %% Web Layer Connections |
| 453 | + WebAPI -->|Authenticates via| Auth |
| 454 | + Auth -->|Authorized requests to| ProcessManager |
| 455 | + WebAPI -->|Real-time updates via| WebSocket |
| 456 | + WebSocket -->|Broadcasts from| SystemMonitor |
| 457 | +
|
| 458 | + %% CLI Connections |
| 459 | + CLI -->|Direct commands to| ProcessManager |
| 460 | +
|
| 461 | + %% Core Layer Connections |
| 462 | + ProcessManager -->|Manages ports via| PortManager |
| 463 | + ProcessManager -->|Loads/saves config via| ConfigService |
| 464 | + ProcessManager -->|Controls processes via| ProcessExecution |
| 465 | + ProcessManager -->|Coordinates monitoring via| HealthMonitor |
| 466 | + ProcessManager -->|Gets metrics from| SystemMonitor |
| 467 | +
|
| 468 | + %% Monitoring Connections |
| 469 | + HealthMonitor -->|Checks health of| ProcessExecution |
| 470 | + ProcessMonitor -->|Monitors individual| ProcessExecution |
| 471 | + SystemMonitor -->|Aggregates data from| ProcessMonitor |
| 472 | +
|
| 473 | + %% Process Layer Connections |
| 474 | + ProcessExecution -->|Handles signals via| SignalHandler |
| 475 | + ProcessExecution -->|Captures logs via| LogManager |
| 476 | + ProcessExecution -->|Uses config from| ConfigService |
| 477 | + ProcessExecution -->|Reports to| ProcessMonitor |
432 | 478 | end |
433 | | - %% Edges at this level (grouped by source) |
434 | | - 17017["User<br>External Actor"] -->|Uses CLI| 17009["CLI Entry Point<br>Rust"] |
435 | | - 17017["User<br>External Actor"] -->|Accesses Web UI/API| 17010["Web API & UI<br>Rust / HTTP"] |
| 479 | +
|
| 480 | + %% External Connections |
| 481 | + User -->|CLI Commands| CLI |
| 482 | + User -->|HTTP/WebSocket| WebAPI |
| 483 | +
|
| 484 | + %% External Systems |
| 485 | + ProcessExecution -->|Spawns & Controls| SystemProcesses["System Processes<br>Managed Applications"] |
| 486 | + ConfigService -->|Persists to| ConfigFiles["Config Files<br>JSON/YAML/TOML"] |
| 487 | + LogManager -->|Writes to| LogFiles["Log Files<br>stdout/stderr"] |
436 | 488 | ``` |
437 | 489 |
|
438 | 490 | ## 🔧 Library Usage |
@@ -484,9 +536,9 @@ cargo test --test e2e_tests |
484 | 536 | ``` |
485 | 537 |
|
486 | 538 | ### Test Coverage |
487 | | -- **267 Total Tests** |
488 | | - - 146 Unit tests (library) |
489 | | - - 32 Unit tests (binary CLI) |
| 539 | +- **272 Total Tests** |
| 540 | + - 150 Unit tests (library) |
| 541 | + - 33 Unit tests (binary CLI) |
490 | 542 | - 13 Integration tests (including config file functionality tests) |
491 | 543 | - 8 End-to-end tests |
492 | 544 | - 8 Configuration format tests |
|
0 commit comments