pgserve 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/cli-install.cjs +15 -8
- package/tests/cli-install.test.js +6 -1
package/package.json
CHANGED
package/src/cli-install.cjs
CHANGED
|
@@ -47,8 +47,13 @@ const DEFAULT_PORT = 8432;
|
|
|
47
47
|
* Revised defaults:
|
|
48
48
|
* - 4G memory ceiling — covers realistic load while still bounded so
|
|
49
49
|
* a runaway query can't eat the host.
|
|
50
|
-
* - 50 max restarts
|
|
51
|
-
* failures
|
|
50
|
+
* - 50 max restarts. Earlier drafts paired this with `--min-uptime` to
|
|
51
|
+
* only count rapid failures, but pm2 ≥ 6.0 dropped `--min-uptime` from
|
|
52
|
+
* the CLI surface (it survives only inside ecosystem files now). We
|
|
53
|
+
* keep the budget generous enough that occasional long-uptime crashes
|
|
54
|
+
* don't burn through it; if you observe restart-budget exhaustion
|
|
55
|
+
* from non-rapid crashes, raise `maxRestarts` rather than reintroducing
|
|
56
|
+
* `--min-uptime` (which would break install on pm2 6.x).
|
|
52
57
|
* - Exponential backoff on repeated failures (100ms → 60s) so we don't
|
|
53
58
|
* hammer on persistent issues.
|
|
54
59
|
* - 60s graceful shutdown window — Postgres needs time to flush WAL.
|
|
@@ -62,7 +67,6 @@ const DEFAULT_PORT = 8432;
|
|
|
62
67
|
*/
|
|
63
68
|
const HARDENED_DEFAULTS = {
|
|
64
69
|
maxRestarts: 50,
|
|
65
|
-
minUptimeMs: 10_000,
|
|
66
70
|
restartDelayMs: 4000,
|
|
67
71
|
expBackoffRestartDelayMs: 100,
|
|
68
72
|
// pm2 caps `--exp-backoff-restart-delay` ramp at the current backoff
|
|
@@ -149,11 +153,14 @@ function buildPm2StartArgs({ scriptPath, port, dataDir }) {
|
|
|
149
153
|
'none',
|
|
150
154
|
'--max-restarts',
|
|
151
155
|
String(HARDENED_DEFAULTS.maxRestarts),
|
|
152
|
-
// `--min-uptime`
|
|
153
|
-
//
|
|
154
|
-
//
|
|
155
|
-
|
|
156
|
-
|
|
156
|
+
// NOTE: pm2 ≥ 6.0 dropped `--min-uptime` from the CLI surface — passing
|
|
157
|
+
// it produces `error: unknown option --min-uptime` and aborts the
|
|
158
|
+
// install. The flag still works inside an ecosystem file, but per the
|
|
159
|
+
// canonical-pm2-supervision wish we keep `pgserve install` as a pure
|
|
160
|
+
// CLI flow (no extra files for operators to manage). The trade-off is
|
|
161
|
+
// that `--max-restarts` now counts every restart (rapid or not) rather
|
|
162
|
+
// than only sub-`min_uptime` ones; the budget of 50 above is sized
|
|
163
|
+
// accordingly.
|
|
157
164
|
'--restart-delay',
|
|
158
165
|
String(HARDENED_DEFAULTS.restartDelayMs),
|
|
159
166
|
// Exponential backoff between successive failures: starts at 100ms,
|
|
@@ -124,7 +124,12 @@ describe('pgserve install', () => {
|
|
|
124
124
|
expect(startCall).toContain('pgserve');
|
|
125
125
|
expect(startCall).toContain('--max-restarts');
|
|
126
126
|
expect(startCall).toContain('50');
|
|
127
|
-
|
|
127
|
+
// pm2 ≥ 6.0 dropped `--min-uptime` from the CLI surface — it now lives
|
|
128
|
+
// only inside ecosystem files. Passing it on the command line aborts
|
|
129
|
+
// `pm2 start` with `error: unknown option --min-uptime`. Lock that out:
|
|
130
|
+
// `pgserve install` must NOT pass `--min-uptime` so it stays compatible
|
|
131
|
+
// across pm2 5.x → 6.x. See cli-install.cjs:HARDENED_DEFAULTS.
|
|
132
|
+
expect(startCall).not.toContain('--min-uptime');
|
|
128
133
|
expect(startCall).toContain('--exp-backoff-restart-delay');
|
|
129
134
|
expect(startCall).toContain('--max-memory-restart');
|
|
130
135
|
expect(startCall).toContain('4G');
|