easy-devops 1.3.5 → 1.4.0
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/README.md +1 -0
- package/dist/ui/assets/index-Bu7af-Kj.css +1 -0
- package/dist/ui/assets/index-gndgYe3K.js +532 -0
- package/dist/ui/assets/socket-Bv0wCEgi.js +65 -0
- package/dist/ui/index.html +2 -2
- package/package.json +2 -2
- package/src/cli/index.js +8 -0
- package/src/cli/managers/domain-manager.js +37 -6
- package/src/cli/managers/nginx-manager.js +14 -5
- package/src/cli/managers/node-manager.js +19 -13
- package/src/cli/managers/ssl-manager.js +89 -26
- package/src/cli/menu.js +8 -2
- package/src/cli/menus/cleanup.js +4 -2
- package/src/cli/menus/dashboard.js +22 -15
- package/src/cli/menus/hub.js +381 -0
- package/src/cli/menus/runtime.js +12 -0
- package/src/cli/menus/service.js +28 -10
- package/src/cli/menus/settings.js +46 -12
- package/src/cli/menus/uninstall.js +13 -5
- package/src/cli/menus/update.js +24 -14
- package/src/cli/ui/page.js +123 -0
- package/src/core/cert-operations.js +34 -4
- package/src/core/cert-reader.js +67 -22
- package/src/core/cert-renewal.js +65 -9
- package/src/core/cert-suggest.js +120 -0
- package/src/core/cleanup.js +221 -1
- package/src/core/cloudflare-ips.js +161 -0
- package/src/core/daemon/ipc.js +1 -1
- package/src/core/daemon/lock.js +296 -9
- package/src/core/dashboardProcess.js +134 -6
- package/src/core/deploy/apps.js +36 -62
- package/src/core/deploy/deployKey.js +331 -0
- package/src/core/deploy/domainLink.js +280 -23
- package/src/core/deploy/engine.js +382 -63
- package/src/core/deploy/ezfile.js +496 -29
- package/src/core/deploy/githubApi.js +100 -13
- package/src/core/deploy/hubCommands.js +158 -18
- package/src/core/deploy/status.js +28 -1
- package/src/core/domains-db.js +1 -0
- package/src/core/hub/agent.js +238 -32
- package/src/core/hub/deployProgress.js +411 -0
- package/src/core/hubConnect.js +205 -0
- package/src/core/hubPermissions.js +48 -10
- package/src/core/jobs/bus.js +1 -1
- package/src/core/jobs/owner.js +268 -6
- package/src/core/nginx-conf-generator.js +124 -19
- package/src/core/notifications/claim.js +26 -3
- package/src/core/permissions.js +277 -59
- package/src/core/platform.js +48 -2
- package/src/core/runner.js +96 -40
- package/src/core/ssl/preflight.js +548 -0
- package/src/core/ssl/progress.js +196 -0
- package/src/core/ssl-issuer.js +502 -148
- package/src/core/validators.js +24 -0
- package/src/dashboard/controllers/authController.js +12 -5
- package/src/dashboard/controllers/deploymentsController.js +76 -11
- package/src/dashboard/controllers/domainsController.js +35 -1
- package/src/dashboard/controllers/hubController.js +4 -3
- package/src/dashboard/controllers/settingsController.js +73 -68
- package/src/dashboard/controllers/sslController.js +135 -15
- package/src/dashboard/public/js/app.js +42 -7
- package/src/dashboard/routes/deployments.js +2 -0
- package/src/dashboard/routes/domains.js +1 -0
- package/src/dashboard/server.js +73 -8
- package/src/dashboard/socketManager.js +19 -25
- package/src/dashboard/views/partials/settings-panel.ejs +29 -10
- package/dist/ui/assets/index-BUpPxWmp.css +0 -1
- package/dist/ui/assets/index-DD0JjK0Q.js +0 -475
- package/dist/ui/assets/socket-4tfdap-e.js +0 -65
package/src/core/runner.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* core/runner.js
|
|
3
3
|
*
|
|
4
|
-
* The one PM2 wrapper. Everything that talks to PM2 — the
|
|
5
|
-
*
|
|
6
|
-
* through here.
|
|
4
|
+
* The one PM2 wrapper. Everything in Easy DevOps that talks to PM2 — the
|
|
5
|
+
* dashboard's Processes page, the Hub agent's process commands and telemetry,
|
|
6
|
+
* and the deploy engine's start/stop of deployed projects — goes through here.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* PM2 is what runs the PROJECTS Easy DevOps deploys, and any PM2 app the user
|
|
9
|
+
* already has. Easy DevOps' own dashboard is not a PM2 app: it runs as a
|
|
10
|
+
* native background service (core/service/), so nothing here should assume an
|
|
11
|
+
* `ez-dashboard` app exists.
|
|
12
12
|
*
|
|
13
13
|
* Rules this module keeps:
|
|
14
14
|
* - Every subprocess call goes through core/shell.js.
|
|
15
15
|
* - Every OS difference comes from core/platform.js.
|
|
16
|
-
* - PM2 is NEVER installed silently. install() exists, but
|
|
17
|
-
*
|
|
16
|
+
* - PM2 is NEVER installed silently. install() exists, but nothing here
|
|
17
|
+
* calls it: a caller must ask the user first.
|
|
18
18
|
* - `run` is injectable on every function so tests can assert the exact
|
|
19
19
|
* command without executing it.
|
|
20
20
|
*/
|
|
@@ -31,11 +31,13 @@ const PM2_TIMEOUT_MS = 60_000;
|
|
|
31
31
|
const INSTALL_TIMEOUT_MS = 300_000;
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* The PM2 app name the dashboard used before it became a native service.
|
|
35
35
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
36
|
+
* Nothing starts the dashboard under PM2 any more. The names are kept because
|
|
37
|
+
* an old install still has such an app on some machines, and it has to be
|
|
38
|
+
* recognised (and removable) rather than mistaken for one of the user's. Dev
|
|
39
|
+
* mode had its own name so a developer's instance could never be mistaken for
|
|
40
|
+
* — or stop — the real one.
|
|
39
41
|
*
|
|
40
42
|
* @param {boolean} dev
|
|
41
43
|
* @returns {string}
|
|
@@ -44,7 +46,7 @@ export function appName(dev) {
|
|
|
44
46
|
return dev ? 'ez-dashboard-dev' : 'ez-dashboard';
|
|
45
47
|
}
|
|
46
48
|
|
|
47
|
-
/** Both names, so callers can recognise anything Easy DevOps created. */
|
|
49
|
+
/** Both legacy names, so callers can recognise anything Easy DevOps created. */
|
|
48
50
|
export const EZ_APP_NAMES = Object.freeze(['ez-dashboard', 'ez-dashboard-dev']);
|
|
49
51
|
|
|
50
52
|
/** @returns {boolean} True when PM2 knows this app name as one of ours. */
|
|
@@ -129,30 +131,6 @@ export async function install({ run = defaultRun } = {}) {
|
|
|
129
131
|
return { ok: r.success, output: combine(r) };
|
|
130
132
|
}
|
|
131
133
|
|
|
132
|
-
/**
|
|
133
|
-
* Installs the pm2-logrotate module, so PM2's logs cannot grow without bound.
|
|
134
|
-
*
|
|
135
|
-
* A PM2 module, not an npm dependency of this project: it is installed into
|
|
136
|
-
* the user's PM2, exactly like PM2 itself.
|
|
137
|
-
*
|
|
138
|
-
* @param {{ run?: Function, pm2Path?: string }} [deps]
|
|
139
|
-
* @returns {Promise<{ ok: boolean, output: string }>}
|
|
140
|
-
*/
|
|
141
|
-
export async function installLogrotate({ run = defaultRun, pm2Path = 'pm2' } = {}) {
|
|
142
|
-
const r = await run(`${quoteExe(pm2Path)} install pm2-logrotate`, { timeout: INSTALL_TIMEOUT_MS });
|
|
143
|
-
return { ok: r.success, output: combine(r) };
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* True when pm2-logrotate is present.
|
|
148
|
-
* @param {{ run?: Function, pm2Path?: string }} [deps]
|
|
149
|
-
* @returns {Promise<boolean>}
|
|
150
|
-
*/
|
|
151
|
-
export async function hasLogrotate({ run = defaultRun, pm2Path = 'pm2' } = {}) {
|
|
152
|
-
const r = await run(`${quoteExe(pm2Path)} ls`, { timeout: PM2_TIMEOUT_MS });
|
|
153
|
-
return /pm2-logrotate/.test(combine(r));
|
|
154
|
-
}
|
|
155
|
-
|
|
156
134
|
/**
|
|
157
135
|
* Lists PM2 apps.
|
|
158
136
|
*
|
|
@@ -185,6 +163,63 @@ export async function list({ run = defaultRun, pm2Path = 'pm2' } = {}) {
|
|
|
185
163
|
return { ok: true, apps: parsed.map(normalizeApp), error: null };
|
|
186
164
|
}
|
|
187
165
|
|
|
166
|
+
/**
|
|
167
|
+
* One app's PM2 status, keyed by name — or null when PM2 does not know it.
|
|
168
|
+
*
|
|
169
|
+
* This is the read the deploy engine uses while it watches a new release for a
|
|
170
|
+
* boot crash: the restart count from `jlist` is what tells "it answered once"
|
|
171
|
+
* apart from "it is crash-looping". It NEVER starts the PM2 daemon. A status
|
|
172
|
+
* read on a machine that does not use PM2 must not create one, so the pid file
|
|
173
|
+
* is checked first and the answer is `daemonRunning: false` instead of a
|
|
174
|
+
* subprocess. `isRunning` is injectable so tests can prove that.
|
|
175
|
+
*
|
|
176
|
+
* @param {string} name PM2 app name
|
|
177
|
+
* @param {{ run?: Function, pm2Path?: string, isRunning?: () => boolean }} [deps]
|
|
178
|
+
* @returns {Promise<{ ok: boolean, app: Object|null, daemonRunning: boolean, error: string|null }>}
|
|
179
|
+
*/
|
|
180
|
+
export async function status(name, { run = defaultRun, pm2Path = 'pm2', isRunning = isDaemonRunning } = {}) {
|
|
181
|
+
const all = await statusAll(name, { run, pm2Path, isRunning });
|
|
182
|
+
if (!all.ok) {
|
|
183
|
+
return { ok: false, app: null, daemonRunning: all.daemonRunning, error: all.error };
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
ok: true,
|
|
187
|
+
app: all.apps[0] ?? null,
|
|
188
|
+
apps: all.apps,
|
|
189
|
+
daemonRunning: true,
|
|
190
|
+
error: null,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Every PM2 entry with one name — a cluster app has one per worker.
|
|
196
|
+
*
|
|
197
|
+
* The same daemon rule as status(): this must never be what starts PM2. A
|
|
198
|
+
* deploy's boot-crash check uses it so one crashing worker among several is
|
|
199
|
+
* not hidden behind the first entry PM2 happens to list.
|
|
200
|
+
*
|
|
201
|
+
* @param {string} name PM2 app name
|
|
202
|
+
* @param {{ run?: Function, pm2Path?: string, isRunning?: () => boolean }} [deps]
|
|
203
|
+
* @returns {Promise<{ ok: boolean, apps: Array<Object>, daemonRunning: boolean, error: string|null }>}
|
|
204
|
+
*/
|
|
205
|
+
export async function statusAll(name, { run = defaultRun, pm2Path = 'pm2', isRunning = isDaemonRunning } = {}) {
|
|
206
|
+
if (!isRunning()) {
|
|
207
|
+
return { ok: false, apps: [], daemonRunning: false, error: 'PM2 is not running.' };
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const listed = await list({ run, pm2Path });
|
|
211
|
+
if (!listed.ok) {
|
|
212
|
+
return { ok: false, apps: [], daemonRunning: true, error: listed.error };
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return {
|
|
216
|
+
ok: true,
|
|
217
|
+
apps: listed.apps.filter((a) => a.name === name),
|
|
218
|
+
daemonRunning: true,
|
|
219
|
+
error: null,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
188
223
|
/**
|
|
189
224
|
* Reduces a `pm2 jlist` entry to the fields the UI needs.
|
|
190
225
|
*
|
|
@@ -209,6 +244,8 @@ export function normalizeApp(app) {
|
|
|
209
244
|
uptimeMs: startedAt && env.status === 'online' ? Math.max(0, Date.now() - startedAt) : null,
|
|
210
245
|
restarts: typeof env.restart_time === 'number' ? env.restart_time : 0,
|
|
211
246
|
unstableRestarts: typeof env.unstable_restarts === 'number' ? env.unstable_restarts : 0,
|
|
247
|
+
/** PM2 reports "cluster_mode" or "fork_mode"; anything else is fork. */
|
|
248
|
+
execMode: String(env.exec_mode ?? '').toLowerCase().includes('cluster') ? 'cluster' : 'fork',
|
|
212
249
|
execPath: env.pm_exec_path ?? null,
|
|
213
250
|
cwd: env.pm_cwd ?? null,
|
|
214
251
|
user: env.username ?? null,
|
|
@@ -279,6 +316,23 @@ export async function reload(name, { run = defaultRun, pm2Path = 'pm2' } = {}) {
|
|
|
279
316
|
return simple('reload', name, run, pm2Path);
|
|
280
317
|
}
|
|
281
318
|
|
|
319
|
+
/**
|
|
320
|
+
* Zero-downtime reload of the app(s) in a config file.
|
|
321
|
+
*
|
|
322
|
+
* `--update-env` matters for a deployment: the new release's environment and
|
|
323
|
+
* working directory come from the file, and PM2 otherwise keeps the ones the
|
|
324
|
+
* process was first started with. Only valid for an app already running in
|
|
325
|
+
* cluster mode; a fork app cannot overlap its old and new process.
|
|
326
|
+
*
|
|
327
|
+
* @param {string} file Absolute path to the PM2 config file
|
|
328
|
+
* @param {{ run?: Function, pm2Path?: string }} [deps]
|
|
329
|
+
* @returns {Promise<{ ok: boolean, output: string }>}
|
|
330
|
+
*/
|
|
331
|
+
export async function reloadConfig(file, { run = defaultRun, pm2Path = 'pm2' } = {}) {
|
|
332
|
+
const r = await run(`${quoteExe(pm2Path)} reload "${file}" --update-env`, { timeout: PM2_TIMEOUT_MS });
|
|
333
|
+
return { ok: r.success, output: combine(r) };
|
|
334
|
+
}
|
|
335
|
+
|
|
282
336
|
/** Removes the app from PM2 entirely. @returns {Promise<{ ok: boolean, output: string }>} */
|
|
283
337
|
export async function del(name, { run = defaultRun, pm2Path = 'pm2' } = {}) {
|
|
284
338
|
return simple('delete', name, run, pm2Path);
|
|
@@ -304,7 +358,8 @@ export async function logs(name, { lines = 200, run = defaultRun, pm2Path = 'pm2
|
|
|
304
358
|
|
|
305
359
|
/**
|
|
306
360
|
* Saves the current process list, so `pm2 resurrect` can restore it.
|
|
307
|
-
* This is what makes a reboot
|
|
361
|
+
* This is what makes DEPLOYED APPS come back after a reboot; the dashboard
|
|
362
|
+
* itself is a native service and does not depend on it.
|
|
308
363
|
* @returns {Promise<{ ok: boolean, output: string }>}
|
|
309
364
|
*/
|
|
310
365
|
export async function save({ run = defaultRun, pm2Path = 'pm2' } = {}) {
|
|
@@ -316,7 +371,8 @@ export async function save({ run = defaultRun, pm2Path = 'pm2' } = {}) {
|
|
|
316
371
|
* Asks PM2 for its init-system startup hook.
|
|
317
372
|
*
|
|
318
373
|
* Linux and macOS only. PM2 has no Windows support here and exits non-zero,
|
|
319
|
-
* which is why Windows
|
|
374
|
+
* which is why the old Windows setup used its own mechanisms — see
|
|
375
|
+
* core/service/legacy.js.
|
|
320
376
|
*
|
|
321
377
|
* PM2 does not install the hook itself when it needs root: it prints a command
|
|
322
378
|
* for the user to run under sudo. That command is returned verbatim rather
|