|
4 | 4 | [](https://www.npmjs.com/package/@hackmd/spm) |
5 | 5 | [](https://www.npmjs.com/package/@hackmd/spm) |
6 | 6 |
|
7 | | -A minimal process manager implementing a lean subset of [pm2](https://pm2.keymetrics.io/) features, with some extensions, designed for better development script setup. Lightweight, zero daemon, and ecosystem config compatible. |
| 7 | +A minimal process manager implementing a lean subset of [pm2](https://pm2.keymetrics.io/) features, with some extensions, designed for better development script setup. Lightweight, zero daemon, and PM2-inspired ecosystem config support. |
8 | 8 |
|
9 | 9 | ## Features |
10 | 10 |
|
@@ -71,13 +71,48 @@ spm logs api -t # Tail logs |
71 | 71 | | `instances` | Number of instances (default: 1) | |
72 | 72 | | `env` | Environment variables | |
73 | 73 | | `increment_vars` | Env vars to increment per instance (e.g. `PORT`) | |
| 74 | +| `increment_var` | Legacy alias for increment vars (comma-separated string, e.g. `PORT,WS_PORT`) | |
| 75 | + |
| 76 | +### Ecosystem File Field Support |
| 77 | + |
| 78 | +SPM supports PM2-inspired ecosystem files and deeper app objects without failing on extra fields. |
| 79 | + |
| 80 | +- SPM **actively uses**: `name`, `script`, `args`, `instances`, `env`, `increment_vars`, `increment_var` |
| 81 | +- SPM **ignores unsupported fields safely** so you can keep partially shared configs across tools |
| 82 | +- `increment_vars` is the preferred form; `increment_var` is kept as a compatibility alias in SPM |
74 | 83 |
|
75 | 84 | Config file is resolved from `./ecosystem.custom.config.js` by default. Override with `--config`: |
76 | 85 |
|
77 | 86 | ```bash |
78 | 87 | spm --config ./my-ecosystem.config.js start |
79 | 88 | ``` |
80 | 89 |
|
| 90 | +## PM2 Differences |
| 91 | + |
| 92 | +SPM intentionally implements a lean subset of PM2 behavior. |
| 93 | + |
| 94 | +- No daemon mode: processes are started detached and tracked with pid files under `~/.spm2/pids/` |
| 95 | +- No PM2 process metadata store: runtime state comes from pid files + OS process checks |
| 96 | +- `increment_vars` is supported directly; `increment_var` is also accepted and split by comma |
| 97 | +- Extra PM2 ecosystem fields are allowed in config objects but not interpreted unless listed in SPM supported fields |
| 98 | + |
| 99 | +Example for split increment vars: |
| 100 | + |
| 101 | +```javascript |
| 102 | +export default { |
| 103 | + apps: [ |
| 104 | + { |
| 105 | + name: 'api', |
| 106 | + script: 'node', |
| 107 | + args: 'server.js', |
| 108 | + instances: 2, |
| 109 | + env: { PORT: '3000', WS_PORT: '4000' }, |
| 110 | + increment_var: 'PORT,WS_PORT', |
| 111 | + }, |
| 112 | + ], |
| 113 | +} |
| 114 | +``` |
| 115 | + |
81 | 116 | ## Commands |
82 | 117 |
|
83 | 118 | | Command | Description | |
|
0 commit comments