Skip to content

Commit bdacdc2

Browse files
- **📚 Documentation Accuracy** - Fixed major discrepancies between docs and implementation
- **🔒 Security Hardening** - Removed dangerous API endpoints and improved security model - **🐛 Critical Bug Fix** - Fixed uptime monitoring showing 0s for all processes - **✅ Production Ready** - Documentation now accurately reflects actual capabilities
1 parent 93f377f commit bdacdc2

315 files changed

Lines changed: 14449 additions & 2100 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ plan/
33
doc/
44
node_modules/
55
assets/site.webmanifest
6+
AGENT.md
7+
TODO.md

CHANGELOG.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,47 @@ All notable changes to PMDaemon will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.1.4] - 2025-05-29
9+
10+
### 🚀 Added
11+
12+
#### **Auto-Generated API Key Management**
13+
- **Persistent API keys**: Secure keys auto-generated on first web server start and saved to `~/.pmdaemon/api-key`
14+
- **Simple management commands**: `show-api-key` and `regenerate-api-key` for easy key management
15+
- **Cross-platform storage**: Reliable key storage across Windows, Linux, and macOS
16+
- **Environment variable support**: `PMDAEMON_API_KEY` still works for advanced use cases
17+
18+
### 🔧 Enhanced
19+
20+
#### **Documentation Accuracy Overhaul**
21+
- **Major corrections**: Fixed 15+ critical documentation inaccuracies that didn't match implementation
22+
- **Load balancing documentation**: Corrected to reflect actual clustering capabilities vs fictional enterprise features
23+
- **API format documentation**: Fixed error response format to match simple `{"success": false, "error": "message"}` structure
24+
- **CLI parameter documentation**: Removed non-existent health check parameters and other fictional options
25+
- **Environment variables**: Updated to show only `PMDAEMON_HOME` (the one that actually works)
26+
- **Library API methods**: Corrected method names to match actual implementation
27+
- **Installation documentation**: Updated for pre-1.0 status (manual installation only)
28+
29+
### 🔒 Security
30+
31+
#### **Enhanced Authentication & Endpoint Security**
32+
- **Removed dangerous endpoints**: Eliminated `POST /api/processes` that allowed arbitrary command execution
33+
- **Automatic authentication**: Web server now auto-generates and uses API keys by default
34+
- **WebSocket security**: Clarified read-only nature to prevent command injection attempts
35+
36+
### 🐛 Fixed
37+
38+
#### **Critical Uptime Monitoring Bug**
39+
- **Process uptime tracking**: Fixed critical bug where all processes showed 0s for uptime values
40+
- **Monitoring data application**: Properly applies collected CPU and memory metrics to process objects
41+
- **Real-time accuracy**: Process monitoring now shows accurate uptime, CPU, and memory usage
42+
43+
### 📊 Technical Details
44+
- **Documentation review**: 35+ files systematically reviewed and corrected
45+
- **Security hardening**: Removed security vulnerabilities from API endpoints
46+
- **API key generation**: Secure 32-character alphanumeric keys with proper entropy
47+
- **Cross-platform compatibility**: API key system works reliably on all supported platforms
48+
849
## [0.1.3]
950

1051
### 🚀 Added
@@ -260,5 +301,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
260301
- System monitoring via sysinfo
261302
- Cross-platform support (Linux, macOS, Windows)
262303

304+
[0.1.4]: https://github.com/entrepeneur4lyf/pmdaemon/compare/v0.1.3...v0.1.4
305+
[0.1.3]: https://github.com/entrepeneur4lyf/pmdaemon/compare/v0.1.2...v0.1.3
306+
[0.1.2]: https://github.com/entrepeneur4lyf/pmdaemon/compare/v0.1.1...v0.1.2
263307
[0.1.1]: https://github.com/entrepeneur4lyf/pmdaemon/compare/v0.1.0...v0.1.1
264308
[0.1.0]: https://github.com/entrepeneur4lyf/pmdaemon/releases/tag/v0.1.0

Cargo.lock

Lines changed: 26 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pmdaemon"
3-
version = "0.1.3"
3+
version = "0.1.4"
44
edition = "2021"
55
description = "PMDaemon - A high-performance, cross-platform process manager built in Rust with advanced port management and monitoring capabilities"
66
license = "MIT"
@@ -78,6 +78,9 @@ uuid = { version = "1.0", features = ["serde", "v4"] }
7878
comfy-table = "7.1.4"
7979
regex = "1.11.1"
8080

81+
# Cryptography for API key generation
82+
rand = "0.8"
83+
8184
[dev-dependencies]
8285
# Testing framework
8386
tempfile = "3.0"
@@ -93,6 +96,7 @@ criterion = { version = "0.5", features = ["html_reports"] }
9396
# Test utilities
9497
pretty_assertions = "1.4"
9598
rstest = "0.18"
99+
tower = { version = "0.4", features = ["util"] }
96100

97101
# Platform-specific dependencies
98102
[target.'cfg(unix)'.dependencies]

README.md

Lines changed: 101 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
<p style="margin: 5px 0 0; color: #cccccc;">A high-performance, cross-platform process manager built in Rust</p>
55
</div>
66

7-
[![Rust](https://img.shields.io/badge/rust-1.70+-orange.svg)](https://www.rust-lang.org)
8-
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
9-
[![Build Status](https://img.shields.io/badge/build-passing-brightgreen.svg)]()
10-
[![Test Coverage](https://img.shields.io/badge/tests-267%20passing-brightgreen.svg)]()
7+
[![GitHub Stars](https://img.shields.io/github/stars/entrepeneur4lyf/pmdaemon?style=flat-square)](https://github.com/entrepeneur4lyf/pmdaemon/stargazers)
8+
[![Crates.io Version](https://img.shields.io/crates/v/pmdaemon?style=flat-square)](https://crates.io/crates/pmdaemon)
9+
[![Crates.io Downloads](https://img.shields.io/crates/d/pmdaemon?style=flat-square)](https://crates.io/crates/pmdaemon)
10+
[![License](https://img.shields.io/badge/license-MIT-blue?style=flat-square)](LICENSE-MIT)
11+
[![Build Status](https://img.shields.io/github/actions/workflow/status/entrepeneur4lyf/pmdaemon/ci.yml?branch=main&style=flat-square)](https://github.com/entrepeneur4lyf/pmdaemon/actions/workflows/ci.yml?query=branch%3Amain)
12+
[![Rust](https://img.shields.io/badge/rust-1.70+-orange.svg?style=flat-square)](https://www.rust-lang.org)
13+
[![Test Coverage](https://img.shields.io/badge/tests-272%20passing-brightgreen.svg?style=flat-square)](https://github.com/entrepeneur4lyf/pmdaemon)
1114

1215
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.
1316

@@ -193,8 +196,11 @@ pmdaemon start api.js --health-check-url http://localhost:9615/status --wait-tim
193196

194197
### Web API Server
195198
```bash
196-
# Start web API server for remote monitoring
199+
# Start web API server for remote monitoring (no authentication)
197200
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"
198204
```
199205

200206
## 📋 Command Reference
@@ -321,28 +327,37 @@ pmdaemon start app.js \
321327

322328
## 🌐 Web API
323329

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
325336

326337
### Endpoints
327338

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 ||
336347

337348
### Example API Usage
338349
```bash
339-
# List processes
340-
curl http://localhost:9615/api/processes
350+
# Start with authentication
351+
pmdaemon web --api-key "your-secret-key"
341352

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
346361

347362
# WebSocket for real-time updates
348363
wscat -c ws://localhost:9615/ws
@@ -406,33 +421,70 @@ PMDaemon provides comprehensive monitoring capabilities:
406421
```mermaid
407422
graph TD
408423
409-
17017["User<br>External Actor"]
410-
subgraph 17008["PMDaemon Application<br>Rust"]
411-
17009["CLI Entry Point<br>Rust"]
412-
17010["Web API &amp; UI<br>Rust / HTTP"]
413-
17011["Core Process Orchestrator<br>Rust"]
414-
17012["Process Execution &amp; State<br>Rust"]
415-
17013["Configuration Service<br>Rust"]
416-
17014["Process Health Monitor<br>Rust"]
417-
17015["Metrics &amp; 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 &amp; UI<br>Rust / HTTP"] -->|Manages processes via| 17011["Core Process Orchestrator<br>Rust"]
422-
17010["Web API &amp; UI<br>Rust / HTTP"] -->|Gets status from| 17015["Metrics &amp; 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 &amp; 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 &amp; 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 &amp; State<br>Rust"]
430-
17015["Metrics &amp; Monitoring<br>Rust"] -->|Collects metrics from| 17012["Process Execution &amp; State<br>Rust"]
431-
17012["Process Execution &amp; 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
432478
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 &amp; 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"]
436488
```
437489

438490
## 🔧 Library Usage
@@ -484,9 +536,9 @@ cargo test --test e2e_tests
484536
```
485537

486538
### 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)
490542
- 13 Integration tests (including config file functionality tests)
491543
- 8 End-to-end tests
492544
- 8 Configuration format tests

0 commit comments

Comments
 (0)