easy-devops 1.3.6 → 1.4.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/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/install.bat +14 -7
- 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 +402 -0
- package/src/cli/menus/runtime.js +12 -0
- package/src/cli/menus/service.js +80 -13
- 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/daemon/run.js +12 -0
- package/src/core/daemon/stateFile.js +128 -0
- package/src/core/dashboardProcess.js +134 -6
- package/src/core/db.js +26 -1
- 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 +73 -2
- package/src/core/runner.js +96 -40
- package/src/core/service/dataDir.js +34 -9
- package/src/core/service/index.js +203 -24
- package/src/core/service/runtime.js +40 -3
- package/src/core/service/windowsService.js +452 -107
- package/src/core/service/winsw.js +44 -3
- 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 +42 -7
- 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
|
@@ -148,6 +148,101 @@ function explain(result, needs) {
|
|
|
148
148
|
return `GitHub answered ${result.status}${result.message ? `: ${result.message}` : ''}.`;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
+
/** The "add a deploy key" page for a github.com repository, or null. */
|
|
152
|
+
export function deployKeyAddUrl(repoUrl) {
|
|
153
|
+
const repo = parseGithubRepo(repoUrl);
|
|
154
|
+
return repo ? `https://github.com/${repo.owner}/${repo.repo}/settings/keys/new` : null;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Type and base64 only: GitHub drops the trailing comment, so compare the material. */
|
|
158
|
+
function keyMaterial(key) {
|
|
159
|
+
return String(key ?? '').trim().split(/\s+/).slice(0, 2).join(' ');
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Adds the app's public key to a github.com repository as a read-only deploy
|
|
164
|
+
* key, and removes an older key with the same title and different material
|
|
165
|
+
* (the key a regeneration replaced).
|
|
166
|
+
*
|
|
167
|
+
* Each step is reported on its own so the UI can say exactly what happened.
|
|
168
|
+
* The old key is only removed after the current one is on the repository, so a
|
|
169
|
+
* failed add never leaves the app locked out.
|
|
170
|
+
*
|
|
171
|
+
* @param {Object} opts
|
|
172
|
+
* @param {string} opts.repoUrl
|
|
173
|
+
* @param {string} opts.token GitHub token, used for this call only
|
|
174
|
+
* @param {string} opts.title
|
|
175
|
+
* @param {string} opts.key The public key line
|
|
176
|
+
* @param {Function} [opts.fetchImpl]
|
|
177
|
+
* @returns {Promise<{ ok: boolean, steps: Array<{ id: string, ok: boolean, detail: string }>,
|
|
178
|
+
* error: string|null }>}
|
|
179
|
+
*/
|
|
180
|
+
export async function addDeployKey({
|
|
181
|
+
repoUrl, token, title, key, fetchImpl = globalThis.fetch,
|
|
182
|
+
}) {
|
|
183
|
+
const repo = parseGithubRepo(repoUrl);
|
|
184
|
+
if (!repo) {
|
|
185
|
+
return { ok: false, steps: [], error: 'Automatic setup works with github.com repositories only.' };
|
|
186
|
+
}
|
|
187
|
+
if (!validateGithubToken(token)) {
|
|
188
|
+
return { ok: false, steps: [], error: 'A GitHub token is required.' };
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const gh = makeClient(token, fetchImpl);
|
|
192
|
+
const base = `/repos/${repo.owner}/${repo.repo}`;
|
|
193
|
+
const material = keyMaterial(key);
|
|
194
|
+
const steps = [];
|
|
195
|
+
|
|
196
|
+
const list = await gh('GET', `${base}/keys?per_page=100`);
|
|
197
|
+
if (!list.ok) {
|
|
198
|
+
return {
|
|
199
|
+
ok: false,
|
|
200
|
+
steps: [{ id: 'deployKey', ok: false, detail: explain(list, '“Administration: read and write”') }],
|
|
201
|
+
error: null,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const keys = Array.isArray(list.json) ? list.json : [];
|
|
206
|
+
const currentPresent = keys.some((k) => keyMaterial(k?.key) === material);
|
|
207
|
+
if (currentPresent) {
|
|
208
|
+
steps.push({ id: 'deployKey', ok: true, detail: 'The deploy key is already on the repository.' });
|
|
209
|
+
} else {
|
|
210
|
+
const add = await gh('POST', `${base}/keys`, { title, key: material, read_only: true });
|
|
211
|
+
steps.push(add.ok
|
|
212
|
+
? { id: 'deployKey', ok: true, detail: 'Added the deploy key, read-only.' }
|
|
213
|
+
: { id: 'deployKey', ok: false, detail: explain(add, '“Administration: read and write”') });
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Only trust a current key that is really there before removing an older one.
|
|
217
|
+
const currentOnRepo = currentPresent || steps[0]?.ok === true;
|
|
218
|
+
const stale = currentOnRepo
|
|
219
|
+
? keys.filter((k) => k?.title === title && keyMaterial(k?.key) !== material)
|
|
220
|
+
: [];
|
|
221
|
+
if (stale.length > 0) {
|
|
222
|
+
const failed = [];
|
|
223
|
+
let removed = 0;
|
|
224
|
+
for (const k of stale) {
|
|
225
|
+
if (k?.id === undefined || k?.id === null) continue;
|
|
226
|
+
const del = await gh('DELETE', `${base}/keys/${encodeURIComponent(k.id)}`);
|
|
227
|
+
if (del.ok) removed += 1;
|
|
228
|
+
else failed.push(explain(del, '“Administration: read and write”'));
|
|
229
|
+
}
|
|
230
|
+
if (failed.length > 0) {
|
|
231
|
+
steps.push({ id: 'oldKey', ok: false, detail: failed.join(' ') });
|
|
232
|
+
} else if (removed > 0) {
|
|
233
|
+
steps.push({
|
|
234
|
+
id: 'oldKey',
|
|
235
|
+
ok: true,
|
|
236
|
+
detail: removed === 1
|
|
237
|
+
? 'Removed the previous deploy key with the same title.'
|
|
238
|
+
: `Removed ${removed} previous deploy keys with the same title.`,
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return { ok: steps.every((s) => s.ok), steps, error: null };
|
|
244
|
+
}
|
|
245
|
+
|
|
151
246
|
/**
|
|
152
247
|
* Applies the setup to a repository.
|
|
153
248
|
*
|
|
@@ -242,19 +337,11 @@ export async function applyGithubSetup({
|
|
|
242
337
|
|
|
243
338
|
// ── deploy key ────────────────────────────────────────────────────────────
|
|
244
339
|
if (deployKey) {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
if (
|
|
249
|
-
|
|
250
|
-
} else if (Array.isArray(list.json) && list.json.some((k) => String(k.key ?? '').trim() === material)) {
|
|
251
|
-
steps.push({ id: 'deployKey', ok: true, detail: 'The deploy key is already on the repository.' });
|
|
252
|
-
} else {
|
|
253
|
-
const add = await gh('POST', `${base}/keys`, { title: deployKey.title, key: deployKey.key, read_only: true });
|
|
254
|
-
steps.push(add.ok
|
|
255
|
-
? { id: 'deployKey', ok: true, detail: 'Added the deploy key, read-only.' }
|
|
256
|
-
: { id: 'deployKey', ok: false, detail: explain(add, '“Administration: read and write”') });
|
|
257
|
-
}
|
|
340
|
+
const added = await addDeployKey({
|
|
341
|
+
repoUrl, token, title: deployKey.title, key: deployKey.key, fetchImpl,
|
|
342
|
+
});
|
|
343
|
+
if (added.steps.length > 0) steps.push(...added.steps);
|
|
344
|
+
else steps.push({ id: 'deployKey', ok: false, detail: added.error ?? 'The deploy key could not be added.' });
|
|
258
345
|
}
|
|
259
346
|
|
|
260
347
|
return { ok: steps.length > 0 && steps.every((s) => s.ok), repo: full, error: null, steps };
|
|
@@ -22,15 +22,17 @@ import { getDomains } from '../domains-db.js';
|
|
|
22
22
|
import { getHubLink, getHubPermissions, resolveHubOrigin } from '../hubLink.js';
|
|
23
23
|
|
|
24
24
|
import {
|
|
25
|
-
getApp, createApp, updateApp, publicApp, normalizeEnv, rotateHookToken, verifyHookToken, validateAppId,
|
|
25
|
+
getApp, createApp, updateApp, publicApp, normalizeEnv, rotateHookToken, verifyHookToken, validateAppId, isSshUrl,
|
|
26
26
|
} from './apps.js';
|
|
27
27
|
import { startDeployment, startRollback, removeRelease, removeApp, moveApp } from './engine.js';
|
|
28
28
|
import { linkDomain, unlinkDomain } from './domainLink.js';
|
|
29
|
-
import { findDomain } from '../domains-db.js';
|
|
30
29
|
import { describeGithubSetup } from './github.js';
|
|
30
|
+
import { addDeployKey, deployKeyAddUrl, validateGithubToken } from './githubApi.js';
|
|
31
|
+
import { generateDeployKey, testDeployKey } from './deployKey.js';
|
|
31
32
|
import { hookSettings } from './hookServer.js';
|
|
32
33
|
import { describeApps, describeAppDetail } from './status.js';
|
|
33
|
-
import { isId, readLogTail, readRun } from './store.js';
|
|
34
|
+
import { isId, lockHolder, readLogTail, readRun } from './store.js';
|
|
35
|
+
import { safeLogText } from '../hub/deployProgress.js';
|
|
34
36
|
|
|
35
37
|
/** An error whose message is safe to show the Hub user as-is. */
|
|
36
38
|
function refuse(message) {
|
|
@@ -67,12 +69,113 @@ export function githubSetupFor(app, view) {
|
|
|
67
69
|
function appInputFromHub(input) {
|
|
68
70
|
const src = input && typeof input === 'object' ? input : {};
|
|
69
71
|
const out = {};
|
|
70
|
-
for (const key of ['repoUrl', 'branch', 'authType', 'token', 'settings', 'keepReleases', 'autoRollback', 'notifyChannelIds']) {
|
|
72
|
+
for (const key of ['repoUrl', 'branch', 'authType', 'token', 'generateKey', 'settings', 'keepReleases', 'autoRollback', 'notifyChannelIds']) {
|
|
71
73
|
if (src[key] !== undefined) out[key] = src[key];
|
|
72
74
|
}
|
|
73
75
|
return out;
|
|
74
76
|
}
|
|
75
77
|
|
|
78
|
+
/**
|
|
79
|
+
* True when a create request asks for the key in the same step. Ignored for
|
|
80
|
+
* every auth type except deployKey; absent means yes for deployKey.
|
|
81
|
+
*/
|
|
82
|
+
export function wantsGeneratedKey(input) {
|
|
83
|
+
return input?.authType === 'deployKey' && input?.generateKey !== false;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Generates a new app's key and shapes the create response's `deployKey`
|
|
88
|
+
* object. A failure is returned as `deployKeyError`: the app exists either way,
|
|
89
|
+
* and the UI can offer "Regenerate key".
|
|
90
|
+
*/
|
|
91
|
+
export function generateKeyForApp(id) {
|
|
92
|
+
try {
|
|
93
|
+
const key = generateDeployKey(id);
|
|
94
|
+
if (!key) return { deployKeyError: `No app named "${id}".` };
|
|
95
|
+
return {
|
|
96
|
+
deployKey: {
|
|
97
|
+
publicKey: key.publicKey,
|
|
98
|
+
fingerprint: key.fingerprint,
|
|
99
|
+
createdAt: key.createdAt,
|
|
100
|
+
addUrl: deployKeyAddUrl(getApp(id)?.repoUrl),
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
} catch (err) {
|
|
104
|
+
return { deployKeyError: err.message };
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Regenerates an app's deploy key. Shared by the dashboard route and the Hub
|
|
110
|
+
* command so both enforce the same auth, URL and deploy-lock rules.
|
|
111
|
+
*
|
|
112
|
+
* @returns {{ ok: true, value: Object } | { ok: false, status: number, error: string }}
|
|
113
|
+
*/
|
|
114
|
+
export function regenerateAppDeployKey(id) {
|
|
115
|
+
const app = typeof id === 'string' ? getApp(id) : null;
|
|
116
|
+
if (!app) return { ok: false, status: 404, error: `No app named "${id}".` };
|
|
117
|
+
if (app.auth?.type !== 'deployKey' || !isSshUrl(app.repoUrl)) {
|
|
118
|
+
return {
|
|
119
|
+
ok: false,
|
|
120
|
+
status: 400,
|
|
121
|
+
error: 'A deploy key needs an app with deployKey authentication and an SSH repository URL.',
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
if (lockHolder(app.id)) {
|
|
125
|
+
return {
|
|
126
|
+
ok: false,
|
|
127
|
+
status: 409,
|
|
128
|
+
error: 'A deployment is running; regenerate the key after it finishes.',
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
try {
|
|
133
|
+
const key = generateDeployKey(app.id);
|
|
134
|
+
if (!key) return { ok: false, status: 404, error: `No app named "${id}".` };
|
|
135
|
+
return {
|
|
136
|
+
ok: true,
|
|
137
|
+
value: {
|
|
138
|
+
publicKey: key.publicKey,
|
|
139
|
+
fingerprint: key.fingerprint,
|
|
140
|
+
createdAt: key.createdAt,
|
|
141
|
+
previousFingerprint: key.previousFingerprint,
|
|
142
|
+
addUrl: deployKeyAddUrl(app.repoUrl),
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
} catch (err) {
|
|
146
|
+
return { ok: false, status: 500, error: err.message };
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Adds an app's public key to GitHub. `token` is a typed token used once; when
|
|
152
|
+
* it is absent the app's own token is tried, exactly as githubApply does.
|
|
153
|
+
*/
|
|
154
|
+
export async function addAppDeployKeyToGithub(id, token, { fetchImpl } = {}) {
|
|
155
|
+
const app = typeof id === 'string' ? getApp(id) : null;
|
|
156
|
+
if (!app) return { ok: false, status: 404, error: `No app named "${id}".` };
|
|
157
|
+
|
|
158
|
+
const typed = typeof token === 'string' ? token.trim() : '';
|
|
159
|
+
const effective = typed || (app.auth?.type === 'token' ? app.auth.token : '');
|
|
160
|
+
const key = app.auth?.publicKey ?? null;
|
|
161
|
+
if (!key) return { ok: false, status: 409, error: 'Generate the deploy key first.' };
|
|
162
|
+
if (!validateGithubToken(effective)) {
|
|
163
|
+
return { ok: false, status: 400, error: 'A GitHub token with write access to the repository is required.' };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const result = await addDeployKey({
|
|
167
|
+
repoUrl: app.repoUrl,
|
|
168
|
+
token: effective,
|
|
169
|
+
title: `Easy DevOps — ${app.id}`,
|
|
170
|
+
key,
|
|
171
|
+
fetchImpl,
|
|
172
|
+
});
|
|
173
|
+
if (result.error) return { ok: false, status: 400, ...result };
|
|
174
|
+
const failed = result.steps.find((s) => !s.ok);
|
|
175
|
+
if (failed) return { ok: false, status: 422, ...result, error: failed.detail };
|
|
176
|
+
return { ok: true, status: 200, ...result };
|
|
177
|
+
}
|
|
178
|
+
|
|
76
179
|
/**
|
|
77
180
|
* Handles a hub:manageDeploy command.
|
|
78
181
|
*
|
|
@@ -81,7 +184,7 @@ function appInputFromHub(input) {
|
|
|
81
184
|
* @param {(run: Object) => void} [opts.onFinished] Called when a deployment or rollback started here ends
|
|
82
185
|
* @returns {Promise<Object>} The command's result data. Throws to refuse.
|
|
83
186
|
*/
|
|
84
|
-
export async function handleHubDeployCommand(payload, { onFinished = null } = {}) {
|
|
187
|
+
export async function handleHubDeployCommand(payload, { onFinished = null, onProgress = null } = {}) {
|
|
85
188
|
const { action, id } = payload ?? {};
|
|
86
189
|
const watch = (started) => {
|
|
87
190
|
if (onFinished) started.done.then((run) => { try { onFinished(run); } catch { /* ignore */ } });
|
|
@@ -109,7 +212,9 @@ export async function handleHubDeployCommand(payload, { onFinished = null } = {}
|
|
|
109
212
|
// A smaller tail than the dashboard's: this travels over the agent
|
|
110
213
|
// socket and through the Hub to a browser.
|
|
111
214
|
const log = readLogTail(app.id, run.id, { maxBytes: 32 * 1024 });
|
|
112
|
-
|
|
215
|
+
// The log on disk is the raw build output. What leaves the server gets
|
|
216
|
+
// the same treatment as live progress: secrets redacted, keys dropped.
|
|
217
|
+
return { ...run, log: safeLogText(log.text, app), logTruncated: log.truncated };
|
|
113
218
|
}
|
|
114
219
|
|
|
115
220
|
case 'deploy': {
|
|
@@ -143,7 +248,30 @@ export async function handleHubDeployCommand(payload, { onFinished = null } = {}
|
|
|
143
248
|
const input = appInputFromHub(payload.app);
|
|
144
249
|
const result = createApp({ ...input, id: String(payload.app?.id ?? '').trim() });
|
|
145
250
|
if (!result.ok) throw refuse(result.errors[0]);
|
|
146
|
-
|
|
251
|
+
// Creating an app never starts a deployment. The key, when asked for, is
|
|
252
|
+
// generated in this same command.
|
|
253
|
+
const extra = wantsGeneratedKey(input) ? generateKeyForApp(result.app.id) : {};
|
|
254
|
+
return { ...publicApp(getApp(result.app.id) ?? result.app), ...extra };
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
case 'regenerateKey': {
|
|
258
|
+
const result = regenerateAppDeployKey(id);
|
|
259
|
+
if (!result.ok) throw refuse(result.error);
|
|
260
|
+
return result.value;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
case 'testKey': {
|
|
264
|
+
requireApp(id);
|
|
265
|
+
return testDeployKey(String(id));
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
case 'addKeyToGithub': {
|
|
269
|
+
const result = await addAppDeployKeyToGithub(id, payload.token);
|
|
270
|
+
// A missing app or key is a refusal; a GitHub failure is a result the
|
|
271
|
+
// caller reads (ok:false, steps, error), exactly like the dashboard.
|
|
272
|
+
if (!result.ok && result.steps === undefined) throw refuse(result.error);
|
|
273
|
+
const { status: _status, ...data } = result;
|
|
274
|
+
return data;
|
|
147
275
|
}
|
|
148
276
|
|
|
149
277
|
case 'update': {
|
|
@@ -171,18 +299,27 @@ export async function handleHubDeployCommand(payload, { onFinished = null } = {}
|
|
|
171
299
|
|
|
172
300
|
case 'linkDomain': {
|
|
173
301
|
requireApp(id);
|
|
174
|
-
|
|
175
|
-
//
|
|
176
|
-
//
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
302
|
+
// Permissions are checked in core/hub/agent.js before this runs: the map
|
|
303
|
+
// there requires deploy.manage + domains.create, plus ssl.issue when the
|
|
304
|
+
// link asks for a new certificate.
|
|
305
|
+
const result = await linkDomain(id, {
|
|
306
|
+
domain: payload.domain,
|
|
307
|
+
www: payload.www,
|
|
308
|
+
ssl: payload.ssl,
|
|
309
|
+
redirect: payload.redirect,
|
|
310
|
+
behindCloudflare: payload.behindCloudflare,
|
|
311
|
+
}, { onProgress });
|
|
184
312
|
if (!result.ok) throw refuse(result.error);
|
|
185
|
-
return {
|
|
313
|
+
return {
|
|
314
|
+
domain: result.domain,
|
|
315
|
+
created: result.created,
|
|
316
|
+
port: result.port,
|
|
317
|
+
www: result.www,
|
|
318
|
+
behindCloudflare: result.behindCloudflare,
|
|
319
|
+
ssl: result.ssl,
|
|
320
|
+
redirect: result.redirect,
|
|
321
|
+
nginxReloaded: result.nginxReloaded,
|
|
322
|
+
};
|
|
186
323
|
}
|
|
187
324
|
|
|
188
325
|
case 'unlinkDomain': {
|
|
@@ -269,6 +406,9 @@ export async function handleHubDeployHook(payload, { onFinished = null } = {}) {
|
|
|
269
406
|
sha: run.sha,
|
|
270
407
|
error: run.error,
|
|
271
408
|
rolledBackTo: run.rolledBackTo ?? null,
|
|
409
|
+
reason: run.reason ?? null,
|
|
410
|
+
logTail: Array.isArray(run.logTail) ? run.logTail : [],
|
|
411
|
+
rollbackSucceeded: run.rollbackSucceeded ?? null,
|
|
272
412
|
startedAt: run.startedAt,
|
|
273
413
|
finishedAt: run.finishedAt,
|
|
274
414
|
},
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import * as defaultRunner from '../runner.js';
|
|
14
14
|
import { listApps, getApp, dashboardApp, pm2Name } from './apps.js';
|
|
15
|
+
import { settingsWarnings } from './ezfile.js';
|
|
15
16
|
import { describeRelease } from './engine.js';
|
|
16
17
|
import { listRuns, readState, listReleases, lockHolder } from './store.js';
|
|
17
18
|
|
|
@@ -30,7 +31,21 @@ export async function pm2Statuses({ runner = defaultRunner } = {}) {
|
|
|
30
31
|
const pm2 = await runner.detect({ probeVersion: false });
|
|
31
32
|
if (!pm2.installed) return byName;
|
|
32
33
|
const listed = await runner.list({ pm2Path: pm2.path ?? 'pm2' });
|
|
33
|
-
if (listed.ok)
|
|
34
|
+
if (listed.ok) {
|
|
35
|
+
for (const app of listed.apps) {
|
|
36
|
+
const existing = byName.get(app.name);
|
|
37
|
+
if (existing) {
|
|
38
|
+
existing.instances.push(app);
|
|
39
|
+
if (app.status === 'online') existing.instancesOnline += 1;
|
|
40
|
+
} else {
|
|
41
|
+
byName.set(app.name, {
|
|
42
|
+
...app,
|
|
43
|
+
instances: [app],
|
|
44
|
+
instancesOnline: app.status === 'online' ? 1 : 0,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
34
49
|
} catch { /* status is decoration; the list still renders */ }
|
|
35
50
|
return byName;
|
|
36
51
|
}
|
|
@@ -47,6 +62,12 @@ export function describeApp(app, processes, view = dashboardApp) {
|
|
|
47
62
|
const runs = listRuns(app.id, { limit: 1 });
|
|
48
63
|
const holder = lockHolder(app.id);
|
|
49
64
|
const proc = processes.get(pm2Name(app.id)) ?? null;
|
|
65
|
+
const live = state.current ? describeRelease(app.id, state.current) : null;
|
|
66
|
+
const execMode = live?.execMode ?? app.settings?.execMode ?? 'fork';
|
|
67
|
+
const warnings = [...(view(app).warnings ?? [])];
|
|
68
|
+
for (const w of settingsWarnings({ execMode })) {
|
|
69
|
+
if (!warnings.includes(w)) warnings.push(w);
|
|
70
|
+
}
|
|
50
71
|
|
|
51
72
|
return {
|
|
52
73
|
...view(app),
|
|
@@ -55,6 +76,12 @@ export function describeApp(app, processes, view = dashboardApp) {
|
|
|
55
76
|
deploying: Boolean(holder),
|
|
56
77
|
activeRunId: holder?.runId ?? null,
|
|
57
78
|
lastRun: runs[0] ?? null,
|
|
79
|
+
/** Advisory notes for the UI; empty unless the app runs a cluster. */
|
|
80
|
+
warnings,
|
|
81
|
+
/** What the live release was started with; settings when it never ran. */
|
|
82
|
+
execMode,
|
|
83
|
+
instances: live?.instances ?? app.settings?.instances ?? 1,
|
|
84
|
+
instancesOnline: proc?.instancesOnline ?? (proc?.status === 'online' ? 1 : 0),
|
|
58
85
|
process: proc
|
|
59
86
|
? {
|
|
60
87
|
status: proc.status, pid: proc.pid, cpu: proc.cpu, memoryBytes: proc.memoryBytes,
|
package/src/core/domains-db.js
CHANGED
|
@@ -88,6 +88,7 @@ export async function handleHubDomainCommand(payload) {
|
|
|
88
88
|
upstreamType: domain.upstreamType ?? DOMAIN_DEFAULTS.upstreamType,
|
|
89
89
|
www: domain.www ?? false,
|
|
90
90
|
wildcard: domain.wildcard ?? false,
|
|
91
|
+
behindCloudflare: domain.behindCloudflare ?? false,
|
|
91
92
|
enabled: true,
|
|
92
93
|
ssl: { ...DOMAIN_DEFAULTS.ssl, ...domain.ssl },
|
|
93
94
|
performance: { ...DOMAIN_DEFAULTS.performance, ...domain.performance },
|