easy-devops 1.3.6 → 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 +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
package/src/core/hub/agent.js
CHANGED
|
@@ -18,7 +18,7 @@ import { getStatus, start as nginxStart, stop as nginxStop, restart as nginxRest
|
|
|
18
18
|
import { publish } from '../jobs/bus.js';
|
|
19
19
|
import { getLastDomainHealth, probeDomains, DOMAIN_HEALTH_POLL_MS } from '../jobs/monitors.js';
|
|
20
20
|
import { isWindows, platformName, isDevDataDir } from '../platform.js';
|
|
21
|
-
import { listAllCerts } from '../cert-reader.js';
|
|
21
|
+
import { listAllCerts, getCertExpiry } from '../cert-reader.js';
|
|
22
22
|
import { backgroundServiceState } from '../service/index.js';
|
|
23
23
|
import * as runner from '../runner.js';
|
|
24
24
|
import { loadChannels } from '../notifier.js';
|
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
COMING_SOON_PERMISSION_IDS,
|
|
37
37
|
checkCommandAllowed,
|
|
38
38
|
} from '../hubPermissions.js';
|
|
39
|
+
import { startDeployProgress, stopDeployProgress } from './deployProgress.js';
|
|
39
40
|
|
|
40
41
|
/** How often the agent checks the shared revision counter. */
|
|
41
42
|
const REVISION_POLL_MS = 3_000;
|
|
@@ -158,11 +159,60 @@ async function pushDomainHealth() {
|
|
|
158
159
|
} catch { /* non-fatal */ }
|
|
159
160
|
}
|
|
160
161
|
|
|
162
|
+
/**
|
|
163
|
+
* Adds the certificate state the dashboard already knows to each domain.
|
|
164
|
+
*
|
|
165
|
+
* Only the status and its label travel — never a path or a certificate body.
|
|
166
|
+
* A configured domain whose certificate directory does not exist yet reports
|
|
167
|
+
* `not_issued`, which is what the Hub needs to say "Not issued yet" instead of
|
|
168
|
+
* showing an error.
|
|
169
|
+
*/
|
|
170
|
+
async function domainsWithCertState(domains) {
|
|
171
|
+
if (!Array.isArray(domains)) return domains;
|
|
172
|
+
|
|
173
|
+
const certByName = new Map();
|
|
174
|
+
try {
|
|
175
|
+
for (const cert of await listAllCerts({ includeUnusable: true })) {
|
|
176
|
+
certByName.set(cert.domain, cert);
|
|
177
|
+
}
|
|
178
|
+
} catch { /* an unreadable certificate directory is not fatal */ }
|
|
179
|
+
|
|
180
|
+
const out = [];
|
|
181
|
+
for (const domain of domains) {
|
|
182
|
+
if (!domain || typeof domain !== 'object') {
|
|
183
|
+
out.push(domain);
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const known = certByName.get(domain.name);
|
|
188
|
+
let certStatus = known?.status ?? null;
|
|
189
|
+
let certLabel = known?.label ?? null;
|
|
190
|
+
|
|
191
|
+
if (!known && domain.name) {
|
|
192
|
+
try {
|
|
193
|
+
const info = await getCertExpiry(domain.name);
|
|
194
|
+
if (info.state === 'not_issued') {
|
|
195
|
+
certStatus = 'not_issued';
|
|
196
|
+
certLabel = 'Not issued yet';
|
|
197
|
+
} else if (info.state === 'unreadable') {
|
|
198
|
+
certStatus = 'unreadable';
|
|
199
|
+
}
|
|
200
|
+
} catch { /* no certificate information for this name */ }
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const next = { ...domain };
|
|
204
|
+
if (certStatus) next.certStatus = certStatus;
|
|
205
|
+
if (certLabel) next.certLabel = certLabel;
|
|
206
|
+
out.push(next);
|
|
207
|
+
}
|
|
208
|
+
return out;
|
|
209
|
+
}
|
|
210
|
+
|
|
161
211
|
async function pushDomainConfigs() {
|
|
162
212
|
if (!socket?.connected) return;
|
|
163
213
|
try {
|
|
164
214
|
const domains = dbGet('domains') || [];
|
|
165
|
-
socket.emit('domain:configs', domains);
|
|
215
|
+
socket.emit('domain:configs', await domainsWithCertState(domains));
|
|
166
216
|
} catch { /* non-fatal */ }
|
|
167
217
|
}
|
|
168
218
|
|
|
@@ -248,11 +298,13 @@ async function pushProcesses() {
|
|
|
248
298
|
async function pushCertExpiry() {
|
|
249
299
|
if (!socket?.connected) return;
|
|
250
300
|
try {
|
|
251
|
-
const certs = await listAllCerts();
|
|
301
|
+
const certs = await listAllCerts({ includeUnusable: true });
|
|
252
302
|
socket.emit('cert:expiry', certs.map(c => ({
|
|
253
303
|
domain: c.domain,
|
|
254
304
|
expiresAt: c.expiry ?? null,
|
|
255
305
|
daysLeft: c.daysLeft ?? null,
|
|
306
|
+
status: c.status ?? null,
|
|
307
|
+
label: c.label ?? null,
|
|
256
308
|
})));
|
|
257
309
|
} catch { /* non-fatal */ }
|
|
258
310
|
}
|
|
@@ -268,10 +320,145 @@ function getPermissions() {
|
|
|
268
320
|
return getHubPermissions();
|
|
269
321
|
}
|
|
270
322
|
|
|
323
|
+
// ─── Live command progress ────────────────────────────────────────────────────
|
|
324
|
+
//
|
|
325
|
+
// A long Hub command (a certificate request, a deployment) used to be silent
|
|
326
|
+
// between its dispatch and its one `command:result`, so the browser could only
|
|
327
|
+
// show "busy". `command:progress` fills that gap. It is deliberately small:
|
|
328
|
+
// a step name, a status and an optional one-line detail — never file contents,
|
|
329
|
+
// paths or anything a secret could hide in.
|
|
330
|
+
//
|
|
331
|
+
// At most five events leave per requestId per second. Beyond that the LAST
|
|
332
|
+
// event of each step is kept and sent when the window reopens, so a step's
|
|
333
|
+
// running → ok/failed pair cannot be lost to the throttle.
|
|
334
|
+
|
|
335
|
+
const PROGRESS_WINDOW_MS = 1_000;
|
|
336
|
+
const PROGRESS_MAX_PER_WINDOW = 5;
|
|
337
|
+
const PROGRESS_DETAIL_MAX = 300;
|
|
338
|
+
const PROGRESS_STATUSES = new Set(['running', 'ok', 'failed', 'skipped']);
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Builds the `onProgress(step, status, detail, domain?)` handed to a command
|
|
342
|
+
* handler.
|
|
343
|
+
*
|
|
344
|
+
* Bound to one requestId. It is a no-op when there is no requestId (nothing to
|
|
345
|
+
* correlate the event with) or when the socket is down, and it never throws:
|
|
346
|
+
* progress is a convenience, and a broken listener must not fail the command
|
|
347
|
+
* that is doing the real work.
|
|
348
|
+
*
|
|
349
|
+
* `domain` is optional and names which domain an SSL stage belongs to; it is
|
|
350
|
+
* what lets renewAll show per-domain progress. Other commands omit it.
|
|
351
|
+
*
|
|
352
|
+
* @param {string|null} requestId
|
|
353
|
+
* @returns {(step: string, status: 'running'|'ok'|'failed'|'skipped', detail?: string, domain?: string) => void}
|
|
354
|
+
*/
|
|
355
|
+
export function createCommandProgress(requestId) {
|
|
356
|
+
if (!requestId) return () => {};
|
|
357
|
+
|
|
358
|
+
let windowStartedAt = 0;
|
|
359
|
+
let sentInWindow = 0;
|
|
360
|
+
let timer = null;
|
|
361
|
+
// step -> newest event held back by the throttle
|
|
362
|
+
const deferred = new Map();
|
|
363
|
+
|
|
364
|
+
const emit = (payload) => {
|
|
365
|
+
try {
|
|
366
|
+
if (socket?.connected) socket.emit('command:progress', payload);
|
|
367
|
+
} catch { /* a progress event must never break the command */ }
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
const flush = () => {
|
|
371
|
+
timer = null;
|
|
372
|
+
try {
|
|
373
|
+
if (!deferred.size) return;
|
|
374
|
+
const now = Date.now();
|
|
375
|
+
if (now - windowStartedAt >= PROGRESS_WINDOW_MS) {
|
|
376
|
+
windowStartedAt = now;
|
|
377
|
+
sentInWindow = 0;
|
|
378
|
+
}
|
|
379
|
+
for (const [step, payload] of [...deferred]) {
|
|
380
|
+
if (sentInWindow >= PROGRESS_MAX_PER_WINDOW) break;
|
|
381
|
+
deferred.delete(step);
|
|
382
|
+
sentInWindow += 1;
|
|
383
|
+
emit(payload);
|
|
384
|
+
}
|
|
385
|
+
if (deferred.size) {
|
|
386
|
+
timer = setTimeout(flush, Math.max(10, windowStartedAt + PROGRESS_WINDOW_MS - Date.now()));
|
|
387
|
+
}
|
|
388
|
+
} catch { /* never throw from a timer */ }
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
return function onProgress(step, status, detail, domain) {
|
|
392
|
+
try {
|
|
393
|
+
if (!socket?.connected) return;
|
|
394
|
+
if (!PROGRESS_STATUSES.has(status)) return;
|
|
395
|
+
|
|
396
|
+
const now = Date.now();
|
|
397
|
+
if (now - windowStartedAt >= PROGRESS_WINDOW_MS) {
|
|
398
|
+
windowStartedAt = now;
|
|
399
|
+
sentInWindow = 0;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
const payload = { requestId, step: String(step), status, at: new Date().toISOString() };
|
|
403
|
+
if (typeof detail === 'string' && detail) {
|
|
404
|
+
payload.detail = detail.length > PROGRESS_DETAIL_MAX
|
|
405
|
+
? detail.slice(0, PROGRESS_DETAIL_MAX)
|
|
406
|
+
: detail;
|
|
407
|
+
}
|
|
408
|
+
if (typeof domain === 'string' && domain.trim()) {
|
|
409
|
+
payload.domain = domain.trim();
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
if (sentInWindow < PROGRESS_MAX_PER_WINDOW) {
|
|
413
|
+
sentInWindow += 1;
|
|
414
|
+
emit(payload);
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
// Over the limit: remember only the newest event for this step.
|
|
419
|
+
// renewAll sends the same step for several domains, so the key includes
|
|
420
|
+
// the domain; otherwise one domain's stage would replace another's.
|
|
421
|
+
deferred.set(`${payload.step}\u0000${payload.domain ?? ''}`, payload);
|
|
422
|
+
if (!timer) {
|
|
423
|
+
timer = setTimeout(flush, Math.max(10, windowStartedAt + PROGRESS_WINDOW_MS - now));
|
|
424
|
+
}
|
|
425
|
+
} catch { /* never throw */ }
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
|
|
271
429
|
/** Emits the acknowledgement the Hub and its browser clients wait for. */
|
|
272
|
-
function sendResult(requestId, ok, { error = null, data = null } = {}) {
|
|
273
|
-
if (!requestId
|
|
274
|
-
|
|
430
|
+
function sendResult(requestId, ok, { error = null, data = null } = {}, ack = null) {
|
|
431
|
+
if (!requestId) return;
|
|
432
|
+
const payload = { requestId, ok, error, data };
|
|
433
|
+
|
|
434
|
+
// A current Hub emits the command WITH a socket.io acknowledgement and
|
|
435
|
+
// answers its HTTP request from it; an older one only relays
|
|
436
|
+
// `command:result`, so both are sent. The ack goes first: the Hub relays a
|
|
437
|
+
// `command:result` it did not consume to the browser, and answering the ack
|
|
438
|
+
// before that lets the HTTP response and the live event tell the same story.
|
|
439
|
+
if (typeof ack === 'function') {
|
|
440
|
+
try { ack(payload); } catch { /* a stale ack must never break the handler */ }
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
if (socket?.connected) socket.emit('command:result', payload);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Logs how long one command took, with its outcome and nothing else.
|
|
448
|
+
*
|
|
449
|
+
* The first run of a command after a Hub restart can be slow (cold imports,
|
|
450
|
+
* certificate scans, a first PM2 read). Without this line that shows up only as
|
|
451
|
+
* a browser timing out, with no way to tell which command was responsible.
|
|
452
|
+
*
|
|
453
|
+
* NEVER log the payload: it can carry environment values, config contents and
|
|
454
|
+
* deploy tokens. The command name, duration and ok/error are enough.
|
|
455
|
+
*
|
|
456
|
+
* @param {string} command
|
|
457
|
+
* @param {number} startedAt Date.now() when handling began
|
|
458
|
+
* @param {boolean} ok
|
|
459
|
+
*/
|
|
460
|
+
function logCommandTiming(command, startedAt, ok) {
|
|
461
|
+
console.log(`[hubAgent] ${command} ${Math.max(0, Date.now() - startedAt)}ms ${ok ? 'ok' : 'error'}`);
|
|
275
462
|
}
|
|
276
463
|
|
|
277
464
|
/**
|
|
@@ -280,27 +467,32 @@ function sendResult(requestId, ok, { error = null, data = null } = {}) {
|
|
|
280
467
|
* @param {string} command
|
|
281
468
|
* @param {Object} payload May carry a requestId added by the Hub
|
|
282
469
|
* @param {(payload: Object) => Promise<Object|void>} fn
|
|
470
|
+
* @param {Function|null} [ack] socket.io acknowledgement, when the Hub waits
|
|
283
471
|
*/
|
|
284
|
-
async function runCommand(command, payload, fn) {
|
|
472
|
+
async function runCommand(command, payload, fn, ack = null) {
|
|
285
473
|
const requestId = payload?.requestId ?? null;
|
|
474
|
+
const startedAt = Date.now();
|
|
286
475
|
|
|
287
476
|
const verdict = checkCommandAllowed(command, payload, getPermissions());
|
|
288
477
|
if (!verdict.allowed) {
|
|
289
478
|
console.warn('[hubAgent] refused', command, '-', verdict.reason);
|
|
290
|
-
|
|
479
|
+
logCommandTiming(command, startedAt, false);
|
|
480
|
+
sendResult(requestId, false, { error: verdict.reason }, ack);
|
|
291
481
|
return;
|
|
292
482
|
}
|
|
293
483
|
|
|
294
484
|
try {
|
|
295
485
|
const data = await fn(payload ?? {});
|
|
296
|
-
|
|
486
|
+
logCommandTiming(command, startedAt, true);
|
|
487
|
+
sendResult(requestId, true, { data: data ?? null }, ack);
|
|
297
488
|
} catch (err) {
|
|
298
489
|
console.error('[hubAgent]', command, 'failed:', err.message);
|
|
299
|
-
|
|
490
|
+
logCommandTiming(command, startedAt, false);
|
|
491
|
+
sendResult(requestId, false, { error: err.message }, ack);
|
|
300
492
|
}
|
|
301
493
|
}
|
|
302
494
|
|
|
303
|
-
async function handleReloadNginx(payload) {
|
|
495
|
+
async function handleReloadNginx(payload, ack) {
|
|
304
496
|
return runCommand('hub:reloadNginx', payload, async () => {
|
|
305
497
|
// Reuse the dashboard's reload path instead of rebuilding the command
|
|
306
498
|
// here: it resolves the nginx.exe path on Windows and uses `sudo -n`.
|
|
@@ -309,10 +501,10 @@ async function handleReloadNginx(payload) {
|
|
|
309
501
|
notifyLocalDashboard('nginx');
|
|
310
502
|
if (!r?.success) throw new Error(r?.output || 'nginx reload failed');
|
|
311
503
|
return { output: r.output ?? '' };
|
|
312
|
-
});
|
|
504
|
+
}, ack);
|
|
313
505
|
}
|
|
314
506
|
|
|
315
|
-
async function handleNginxAction(payload) {
|
|
507
|
+
async function handleNginxAction(payload, ack) {
|
|
316
508
|
return runCommand('hub:nginxAction', payload, async ({ action }) => {
|
|
317
509
|
const actions = {
|
|
318
510
|
start: nginxStart, stop: nginxStop, restart: nginxRestart, test: nginxTest,
|
|
@@ -325,10 +517,10 @@ async function handleNginxAction(payload) {
|
|
|
325
517
|
notifyLocalDashboard('nginx');
|
|
326
518
|
if (r && r.success === false) throw new Error(r.output || `nginx ${action} failed`);
|
|
327
519
|
return { action, output: r?.output ?? '' };
|
|
328
|
-
});
|
|
520
|
+
}, ack);
|
|
329
521
|
}
|
|
330
522
|
|
|
331
|
-
async function handleGetConfigs(payload) {
|
|
523
|
+
async function handleGetConfigs(payload, ack) {
|
|
332
524
|
return runCommand('hub:getConfigs', payload, async () => {
|
|
333
525
|
const files = await listConfigs();
|
|
334
526
|
const configs = [];
|
|
@@ -340,7 +532,7 @@ async function handleGetConfigs(payload) {
|
|
|
340
532
|
}
|
|
341
533
|
if (socket?.connected) socket.emit('nginx:configs', configs);
|
|
342
534
|
return { count: configs.length };
|
|
343
|
-
});
|
|
535
|
+
}, ack);
|
|
344
536
|
}
|
|
345
537
|
|
|
346
538
|
/**
|
|
@@ -378,7 +570,7 @@ export function resolveSaveConfigReload(payload, permissions) {
|
|
|
378
570
|
};
|
|
379
571
|
}
|
|
380
572
|
|
|
381
|
-
async function handleSaveConfig(payload) {
|
|
573
|
+
async function handleSaveConfig(payload, ack) {
|
|
382
574
|
return runCommand('hub:saveConfig', payload, async (body) => {
|
|
383
575
|
const { filename, content } = body;
|
|
384
576
|
if (typeof filename !== 'string' || !filename.trim()) throw new Error('filename is required');
|
|
@@ -420,18 +612,18 @@ async function handleSaveConfig(payload) {
|
|
|
420
612
|
pushDomainConfigs();
|
|
421
613
|
notifyLocalDashboard('nginx');
|
|
422
614
|
return result;
|
|
423
|
-
});
|
|
615
|
+
}, ack);
|
|
424
616
|
}
|
|
425
617
|
|
|
426
|
-
async function handleGetLogs(payload) {
|
|
618
|
+
async function handleGetLogs(payload, ack) {
|
|
427
619
|
return runCommand('hub:getLogs', payload, async ({ lines }) => {
|
|
428
620
|
const result = await getLogs(lines ?? 200);
|
|
429
621
|
if (socket?.connected) socket.emit('nginx:logs', result);
|
|
430
622
|
return { lines: result?.lines?.length ?? 0 };
|
|
431
|
-
});
|
|
623
|
+
}, ack);
|
|
432
624
|
}
|
|
433
625
|
|
|
434
|
-
async function handleManageDomain(payload) {
|
|
626
|
+
async function handleManageDomain(payload, ack) {
|
|
435
627
|
return runCommand('hub:manageDomain', payload, async (p) => {
|
|
436
628
|
const { handleHubDomainCommand } = await import('../domains-db.js');
|
|
437
629
|
const result = await handleHubDomainCommand(p);
|
|
@@ -442,20 +634,22 @@ async function handleManageDomain(payload) {
|
|
|
442
634
|
pushDomainConfigs();
|
|
443
635
|
notifyLocalDashboard('domains');
|
|
444
636
|
return result ?? null;
|
|
445
|
-
});
|
|
637
|
+
}, ack);
|
|
446
638
|
}
|
|
447
639
|
|
|
448
|
-
async function handleManageSSL(payload) {
|
|
640
|
+
async function handleManageSSL(payload, ack) {
|
|
449
641
|
return runCommand('hub:manageSSL', payload, async (p) => {
|
|
450
642
|
const { handleHubSslCommand } = await import('../cert-operations.js');
|
|
451
|
-
const result = await handleHubSslCommand(p
|
|
643
|
+
const result = await handleHubSslCommand(p, {
|
|
644
|
+
onProgress: createCommandProgress(p?.requestId),
|
|
645
|
+
});
|
|
452
646
|
if (result && result.ok === false) throw new Error(result.error || 'ssl command failed');
|
|
453
647
|
|
|
454
648
|
pushCertExpiry();
|
|
455
649
|
pushDomainConfigs();
|
|
456
650
|
notifyLocalDashboard('ssl');
|
|
457
651
|
return result ?? null;
|
|
458
|
-
});
|
|
652
|
+
}, ack);
|
|
459
653
|
}
|
|
460
654
|
|
|
461
655
|
/**
|
|
@@ -474,27 +668,30 @@ async function pushDeployApps() {
|
|
|
474
668
|
} catch { /* non-fatal */ }
|
|
475
669
|
}
|
|
476
670
|
|
|
477
|
-
async function handleManageDeploy(payload) {
|
|
671
|
+
async function handleManageDeploy(payload, ack) {
|
|
478
672
|
return runCommand('hub:manageDeploy', payload, async (p) => {
|
|
479
673
|
const { handleHubDeployCommand } = await import('../deploy/hubCommands.js');
|
|
480
674
|
try {
|
|
481
|
-
return await handleHubDeployCommand(p, {
|
|
675
|
+
return await handleHubDeployCommand(p, {
|
|
676
|
+
onFinished: () => { pushDeployApps(); },
|
|
677
|
+
onProgress: createCommandProgress(p?.requestId),
|
|
678
|
+
});
|
|
482
679
|
} finally {
|
|
483
680
|
// Whatever the action was, the list is the thing that may have changed.
|
|
484
681
|
if (!['list', 'detail', 'run', 'github', 'getEnv'].includes(p?.action)) pushDeployApps();
|
|
485
682
|
// Linking or deleting with a domain changes the domain list too.
|
|
486
683
|
if (['linkDomain', 'delete'].includes(p?.action)) { pushDomainConfigs(); pushDomainHealth(); notifyLocalDashboard('domains'); }
|
|
487
684
|
}
|
|
488
|
-
});
|
|
685
|
+
}, ack);
|
|
489
686
|
}
|
|
490
687
|
|
|
491
|
-
async function handleDeployHook(payload) {
|
|
688
|
+
async function handleDeployHook(payload, ack) {
|
|
492
689
|
return runCommand('hub:deployHook', payload, async (p) => {
|
|
493
690
|
const { handleHubDeployHook } = await import('../deploy/hubCommands.js');
|
|
494
691
|
const result = await handleHubDeployHook(p, { onFinished: () => { pushDeployApps(); } });
|
|
495
692
|
if (result?.started) pushDeployApps();
|
|
496
693
|
return result;
|
|
497
|
-
});
|
|
694
|
+
}, ack);
|
|
498
695
|
}
|
|
499
696
|
|
|
500
697
|
/**
|
|
@@ -548,7 +745,7 @@ async function handleManageProcess(payload) {
|
|
|
548
745
|
// keep showing the old status until the next 60-second heartbeat.
|
|
549
746
|
pushProcesses();
|
|
550
747
|
return { name, action, managed: Boolean(app.managed), output: result.output ?? '' };
|
|
551
|
-
});
|
|
748
|
+
}, ack);
|
|
552
749
|
}
|
|
553
750
|
|
|
554
751
|
// ─── Permission + revision sync ───────────────────────────────────────────────
|
|
@@ -603,7 +800,7 @@ async function checkRevision() {
|
|
|
603
800
|
* and the transport is someone else's problem: a dashboard running the jobs
|
|
604
801
|
* itself forwards it to its own browsers, and the daemon forwards it over IPC
|
|
605
802
|
* to a dashboard in another process. The payload is unchanged, so
|
|
606
|
-
*
|
|
803
|
+
* API-CONTRACT.md still describes it exactly.
|
|
607
804
|
*
|
|
608
805
|
* @param {'domains'|'ssl'|'nginx'|'settings'} section
|
|
609
806
|
*/
|
|
@@ -718,11 +915,18 @@ export function initHubAgent() {
|
|
|
718
915
|
const { sslDir } = loadConfig();
|
|
719
916
|
self.emit('server:info', { platform: platformName, sslDir: sslDir ?? '' });
|
|
720
917
|
startHeartbeats();
|
|
918
|
+
startDeployProgress({
|
|
919
|
+
emit: (event, payload) => {
|
|
920
|
+
if (socket === self && self.connected) self.emit(event, payload);
|
|
921
|
+
},
|
|
922
|
+
onAppsChanged: () => pushDeployApps(),
|
|
923
|
+
});
|
|
721
924
|
});
|
|
722
925
|
|
|
723
926
|
self.on('disconnect', (reason) => {
|
|
724
927
|
if (!isCurrent()) return;
|
|
725
928
|
console.log('[hubAgent] Disconnected:', reason);
|
|
929
|
+
stopDeployProgress();
|
|
726
930
|
stopHeartbeats();
|
|
727
931
|
|
|
728
932
|
if (agentState.status === HUB_AGENT_STATUS.CONNECTED) {
|
|
@@ -770,6 +974,7 @@ export function initHubAgent() {
|
|
|
770
974
|
if (!isCurrent()) return;
|
|
771
975
|
cancelRejoin();
|
|
772
976
|
setState(HUB_AGENT_STATUS.REJECTED, describeRejection(message));
|
|
977
|
+
stopDeployProgress();
|
|
773
978
|
stopHeartbeats();
|
|
774
979
|
return;
|
|
775
980
|
}
|
|
@@ -866,6 +1071,7 @@ export function reconcileHubAgent() {
|
|
|
866
1071
|
}
|
|
867
1072
|
|
|
868
1073
|
export function stopHubAgent() {
|
|
1074
|
+
stopDeployProgress();
|
|
869
1075
|
stopHeartbeats();
|
|
870
1076
|
cancelRejoin();
|
|
871
1077
|
activeLink = null;
|