@animastor/installer 0.2.4 → 0.2.9
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 +76 -12
- package/ai/install-manifests/image/qwen-image.json +3 -3
- package/ai/install-manifests/video/ltx-2.3.json +9 -9
- package/package.json +1 -1
- package/src/installer/cli.js +524 -70
- package/src/installer/engine/engine.js +153 -8
- package/src/installer/engine/node-deps.js +330 -44
- package/src/installer/engine/overrides.js +375 -0
- package/src/installer/engine/pydeps.js +204 -0
- package/src/installer/engine/summary.js +17 -1
- package/src/installer/engine/worker.js +359 -7
- package/src/installer/management.js +6 -1
- package/src/installer/verification-report.js +19 -5
package/src/installer/cli.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* animastor-installer verify [--profile P[,P2]] [--root PATH] [--worker-dir PATH] [--hub-url URL]
|
|
14
14
|
* animastor-installer resume
|
|
15
15
|
* animastor-installer uninstall [--all] [--yes] [--dry-run] [--state PATH] [--home PATH]
|
|
16
|
-
* animastor-installer start | stop | status | logs [-f] [--lines N] | doctor [--new-key]
|
|
16
|
+
* animastor-installer start | stop | status | logs [-f] [--lines N] | doctor [--new-key] [--wait-job-ms N] [--force]
|
|
17
17
|
* animastor-installer boot (node startup script: detaches `doctor --yes`, exits 0 at once)
|
|
18
18
|
* (what the `animastor` command in PATH runs)
|
|
19
19
|
*
|
|
@@ -29,6 +29,11 @@
|
|
|
29
29
|
* --yes Auto-confirm all prompts
|
|
30
30
|
* --dry-run Show plan only; never perform real changes
|
|
31
31
|
* --all uninstall: full uninstall (everything recorded in the manifest)
|
|
32
|
+
* --wait-job-ms N install/doctor: when the worker must be restarted (its .env or bundle
|
|
33
|
+
* changed) but is busy with a task, wait up to N ms for the task to
|
|
34
|
+
* finish (default 600000); still busy → FAILED, exit 1
|
|
35
|
+
* --force install/doctor: restart the worker for a changed configuration even
|
|
36
|
+
* when it is busy (the task's result is lost)
|
|
32
37
|
*/
|
|
33
38
|
|
|
34
39
|
const fs = require('fs');
|
|
@@ -55,6 +60,8 @@ const workerMod = require('./engine/worker');
|
|
|
55
60
|
const comfyuiMod = require('./engine/comfyui');
|
|
56
61
|
const comfyOwner = require('./engine/comfy-owner');
|
|
57
62
|
const nodeDeps = require('./engine/node-deps');
|
|
63
|
+
const pydepsMod = require('./engine/pydeps');
|
|
64
|
+
const overridesMod = require('./engine/overrides');
|
|
58
65
|
const downloader = require('./engine/downloader');
|
|
59
66
|
const { resolveRepoBundleDir } = require('./worker-bundle-source');
|
|
60
67
|
const engineMod = require('./engine/engine');
|
|
@@ -106,31 +113,74 @@ const DEFAULT_HUB_URL = 'https://animastor.org/gpu';
|
|
|
106
113
|
// Argument parsing
|
|
107
114
|
// ---------------------------------------------------------------------------
|
|
108
115
|
|
|
109
|
-
const BOOLEAN_FLAGS = ['yes', 'dry-run', 'resume', 'start-comfy', 'start-worker', 'no-start-comfy', 'no-start-worker', 'all', 'accept-reference-runtime', 'accept-runtime-change', 'install-tools', 'no-tools', 'new-key', 'follow', 'no-fix', 'restart-platform-comfy', 'no-restart-platform-comfy'];
|
|
116
|
+
const BOOLEAN_FLAGS = ['yes', 'dry-run', 'resume', 'start-comfy', 'start-worker', 'no-start-comfy', 'no-start-worker', 'all', 'accept-reference-runtime', 'accept-runtime-change', 'install-tools', 'no-tools', 'new-key', 'follow', 'no-fix', 'restart-platform-comfy', 'no-restart-platform-comfy', 'accept-node-deps-overrides', 'force', 'help'];
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Every option that takes a value. Installer 0.2.5: an option that is in
|
|
120
|
+
* neither list is an ERROR (exit 2) — installer 0.2.3 silently swallowed
|
|
121
|
+
* `doctor --restart-platform-comfy` (a flag it did not know) and ran a plain
|
|
122
|
+
* doctor, which printed the same fix again (live E2E 02.11).
|
|
123
|
+
*/
|
|
124
|
+
const VALUE_FLAGS = ['profile', 'mode', 'root', 'worker-dir', 'hub-url', 'repo-root', 'state', 'tools-dir',
|
|
125
|
+
'comfy-port', 'comfy-wait-ms', 'verify-timeout-ms', 'port', 'lines', 'history-max', 'home', 'boot-log', 'wait-job-ms'];
|
|
126
|
+
|
|
127
|
+
/** Commands main() dispatches. */
|
|
128
|
+
const COMMANDS = ['detect', 'plan', 'install', 'verify', 'validate', 'resume', 'uninstall', 'start', 'stop', 'status',
|
|
129
|
+
'logs', 'doctor', 'boot', 'monitor', 'reboot-worker', 'reboot-comfyui'];
|
|
130
|
+
|
|
131
|
+
/** Exit code of a command line the CLI does not understand. */
|
|
132
|
+
const USAGE_EXIT = 2;
|
|
110
133
|
|
|
111
134
|
function parseArgs(argv) {
|
|
112
135
|
const args = argv.slice(2);
|
|
113
|
-
const parsed = { command: null, profiles: [], flags: {} };
|
|
136
|
+
const parsed = { command: null, profiles: [], flags: {}, errors: [] };
|
|
114
137
|
const positional = [];
|
|
115
138
|
for (let i = 0; i < args.length; i++) {
|
|
116
139
|
const a = args[i];
|
|
117
140
|
if (a.startsWith('--')) {
|
|
118
|
-
|
|
141
|
+
let key = a.slice(2);
|
|
142
|
+
let inline = null;
|
|
143
|
+
const eq = key.indexOf('=');
|
|
144
|
+
if (eq > 0) { inline = key.slice(eq + 1); key = key.slice(0, eq); }
|
|
119
145
|
if (BOOLEAN_FLAGS.includes(key)) {
|
|
146
|
+
if (inline !== null) parsed.errors.push(`option --${key} takes no value (got --${key}=${inline})`);
|
|
120
147
|
parsed.flags[key] = true;
|
|
148
|
+
} else if (VALUE_FLAGS.includes(key)) {
|
|
149
|
+
let val = inline;
|
|
150
|
+
if (val === null) {
|
|
151
|
+
const next = args[i + 1];
|
|
152
|
+
if (next === undefined || (next.startsWith('--') && next.length > 2)) {
|
|
153
|
+
parsed.errors.push(`option --${key} needs a value`);
|
|
154
|
+
val = '';
|
|
155
|
+
} else {
|
|
156
|
+
val = next;
|
|
157
|
+
i += 1;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
parsed.flags[key] = val;
|
|
121
161
|
} else {
|
|
122
|
-
|
|
123
|
-
parsed.flags[key] = val || '';
|
|
162
|
+
parsed.errors.push(`unknown option --${key}`);
|
|
124
163
|
}
|
|
125
164
|
} else if (a === '-f') {
|
|
126
165
|
parsed.flags.follow = true;
|
|
127
166
|
} else if (a === '-y') {
|
|
128
167
|
parsed.flags.yes = true;
|
|
168
|
+
} else if (a === '-h') {
|
|
169
|
+
parsed.flags.help = true;
|
|
170
|
+
} else if (a.startsWith('-') && a.length > 1) {
|
|
171
|
+
parsed.errors.push(`unknown option ${a}`);
|
|
129
172
|
} else {
|
|
130
173
|
positional.push(a);
|
|
131
174
|
}
|
|
132
175
|
}
|
|
176
|
+
const wj = parsed.flags['wait-job-ms'];
|
|
177
|
+
if (wj !== undefined && wj !== '' && !(/^\d+$/.test(String(wj)))) {
|
|
178
|
+
parsed.errors.push(`option --wait-job-ms needs a number of milliseconds >= 0 (got ${wj})`);
|
|
179
|
+
}
|
|
133
180
|
parsed.command = positional[0] || null;
|
|
181
|
+
if (positional.length > 1) parsed.errors.push(`unexpected argument(s): ${positional.slice(1).join(' ')}`);
|
|
182
|
+
// An unknown COMMAND keeps its old behaviour: usage + exit 1 (main()).
|
|
183
|
+
parsed.unknownCommand = parsed.command !== null && !COMMANDS.includes(parsed.command);
|
|
134
184
|
const profileFlag = parsed.flags.profile || '';
|
|
135
185
|
if (profileFlag) {
|
|
136
186
|
parsed.profiles = profileFlag.split(',').map((s) => s.trim()).filter(Boolean);
|
|
@@ -475,7 +525,10 @@ function platformComfyMissingResult({ waited, tool, mode }) {
|
|
|
475
525
|
* explicit flag wins, then the recorded answer (install-state
|
|
476
526
|
* installer_options.restartPlatformComfy), then the boot default: yes on
|
|
477
527
|
* type A — the node is unattended and nothing else brings the node classes
|
|
478
|
-
* back. An interactive run without a record asks (
|
|
528
|
+
* back. An interactive run without a record asks (default Yes) and records
|
|
529
|
+
* the answer. A plain `--yes` is NOT consent to stop a process the installer
|
|
530
|
+
* does not own (installer 0.2.5 ADR): it needs the flag, a recorded yes, or
|
|
531
|
+
* the boot run.
|
|
479
532
|
* @returns {{ allowed: boolean|null, source: 'flag'|'state'|'boot'|'unset' }}
|
|
480
533
|
*/
|
|
481
534
|
function restartPlatformComfyDecision(flags, state, { boot = false } = {}) {
|
|
@@ -487,106 +540,324 @@ function restartPlatformComfyDecision(flags, state, { boot = false } = {}) {
|
|
|
487
540
|
return { allowed: null, source: 'unset' };
|
|
488
541
|
}
|
|
489
542
|
|
|
490
|
-
const RESTART_PLATFORM_QUESTION = '
|
|
543
|
+
const RESTART_PLATFORM_QUESTION = 'When the custom-node dependencies have to be (re)installed, may animastor (also `animastor boot`) restart the platform\'s ComfyUI with the same command line so the nodes load?';
|
|
491
544
|
|
|
492
545
|
/**
|
|
493
|
-
* The custom-node dependency gate
|
|
494
|
-
*
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
*
|
|
498
|
-
*
|
|
499
|
-
*
|
|
500
|
-
*
|
|
546
|
+
* The custom-node dependency gate for a ComfyUI that the PLATFORM runs
|
|
547
|
+
* (type A; installer 0.2.4, persistence + restart reworked in 0.2.5):
|
|
548
|
+
*
|
|
549
|
+
* 1. the pip requirements of every required profile node are checked in
|
|
550
|
+
* the Python of the running main.py — with the persistent overlay
|
|
551
|
+
* (~/animastor/pydeps, engine/pydeps.js) in front of sys.path, exactly
|
|
552
|
+
* as ComfyUI sees it after the generated prestartup script;
|
|
553
|
+
* 2. missing ones are installed (boot / --yes / --restart-platform-comfy:
|
|
554
|
+
* no question; interactive: one question that also records the restart
|
|
555
|
+
* option) INTO THE OVERLAY — it lives in /home and survives a node
|
|
556
|
+
* restart; only when the overlay is impossible (old ComfyUI without
|
|
557
|
+
* prestartup scripts, no venv module) into the platform Python as in
|
|
558
|
+
* 0.2.4 (lost with a restart — boot reinstalls them);
|
|
559
|
+
* 3. the running ComfyUI loads new packages only on a restart: when the
|
|
560
|
+
* node classes are not in its /object_info and restarting the
|
|
561
|
+
* platform's ComfyUI is allowed, it is restarted with the same command
|
|
562
|
+
* line, cwd and environment (node-deps restartForeignComfyUI).
|
|
563
|
+
* @returns {Promise<{ instance, checked: boolean, installed: string[], restarted: boolean, pid_changed: boolean, failed: boolean, reason: string|null, fix?: string, record: object, persistence: object|null, prestartup: object|null }>}
|
|
564
|
+
*/
|
|
565
|
+
/**
|
|
566
|
+
* Compare the overlay with the platform Python and log every replacement
|
|
567
|
+
* (installer 0.2.6): "[i] <pkg> platform X → overlay Y (needed by <node>)",
|
|
568
|
+
* a major change as a warning. Null when the comparison itself failed.
|
|
569
|
+
* @returns {{ overrides: object[], conflicts: object[] }|null}
|
|
501
570
|
*/
|
|
571
|
+
function overridesStep(io, { python, sitePackages, root, manifests = [], otherManifests = [], info, warn }) {
|
|
572
|
+
const all = [...(manifests || []), ...(otherManifests || [])];
|
|
573
|
+
const nodes = overridesMod.nodesOfProfiles(io, { root, manifests: all });
|
|
574
|
+
const raw = overridesMod.inspectOverlay(io, { python, sitePackages, root, nodes });
|
|
575
|
+
if (!raw.ok) {
|
|
576
|
+
warn(`overlay version comparison failed: ${raw.error}`);
|
|
577
|
+
return null;
|
|
578
|
+
}
|
|
579
|
+
const res = overridesMod.analyzeOverrides(raw, nodes, { profileCount: overridesMod.profileIds(all).length });
|
|
580
|
+
for (const o of res.overrides) {
|
|
581
|
+
const line = `node-deps overlay replaces a platform package: ${overridesMod.describeOverride(o)}`;
|
|
582
|
+
if (o.major) warn(`${line}${overridesMod.majorNote(o)}`);
|
|
583
|
+
else info(line);
|
|
584
|
+
}
|
|
585
|
+
return res;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/** Manifests of the profiles recorded on this ComfyUI that this run does not install (unknown ids are skipped). */
|
|
589
|
+
function otherProfileManifests(priorState, profiles, { load = manifest.loadManifest, logger = null } = {}) {
|
|
590
|
+
const ids = new Set();
|
|
591
|
+
for (const p of (priorState && Array.isArray(priorState.profiles) ? priorState.profiles : [])) ids.add(p);
|
|
592
|
+
const nd = priorState && priorState.installer_options && priorState.installer_options.nodeDeps;
|
|
593
|
+
for (const o of (nd && Array.isArray(nd.overrides) ? nd.overrides : [])) for (const p of o.profiles || []) ids.add(p);
|
|
594
|
+
const out = [];
|
|
595
|
+
for (const id of ids) {
|
|
596
|
+
if ((profiles || []).includes(id)) continue;
|
|
597
|
+
try { out.push(load(id)); } catch (err) {
|
|
598
|
+
if (logger) logger.warn(`profile ${id} recorded on this ComfyUI is unknown to this installer — not checked for version replacements (${err.message})`);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
return out;
|
|
602
|
+
}
|
|
603
|
+
|
|
502
604
|
async function platformNodeDepsGate(io, {
|
|
503
605
|
instance, state = null, root, manifests, flags = {}, boot = false, yes = false, prompt = null,
|
|
504
606
|
waitMs = 600000, logger = null, statePath = null, sleep = null, intervalMs = 3000, progressMs = 30000,
|
|
607
|
+
workerDir = null, platformGraceMs = 30000, otherManifests = [], command = 'doctor',
|
|
505
608
|
} = {}) {
|
|
506
|
-
const out = {
|
|
609
|
+
const out = {
|
|
610
|
+
instance, checked: false, installed: [], restarted: false, pid_changed: false, failed: false, reason: null, record: {},
|
|
611
|
+
persistence: null, prestartup: null, overrides: [], conflicts: [],
|
|
612
|
+
};
|
|
507
613
|
if (!instance || instance.owner !== 'foreign' || !instance.pid) return out;
|
|
508
614
|
const info = (line) => { if (logger) logger.info(line); };
|
|
509
615
|
const warn = (line) => { if (logger) logger.warn(line); };
|
|
510
616
|
const decision = restartPlatformComfyDecision(flags, state, { boot });
|
|
511
617
|
let restartAllowed = decision.allowed;
|
|
512
618
|
const interactive = !boot && !yes && !!(prompt && prompt.available);
|
|
619
|
+
const tool = toolCommandPath(flags);
|
|
513
620
|
|
|
514
621
|
const py = nodeDeps.pythonOfProcess(io, instance.pid);
|
|
515
622
|
if (!py.python) {
|
|
516
623
|
warn(`custom-node dependencies not checked: the Python of the ComfyUI process (pid ${instance.pid}) is unknown (${py.source})`);
|
|
517
624
|
return out;
|
|
518
625
|
}
|
|
519
|
-
const
|
|
626
|
+
const base = workerDir ? pydepsMod.overlayBase(workerDir) : null;
|
|
627
|
+
let persist = pydepsMod.planPersistence(io, { python: py.python, root, base, create: false });
|
|
628
|
+
const overlayReady = () => persist.kind === 'overlay' && persist.paths && io.fs.existsSync(persist.paths.cfg);
|
|
629
|
+
const extraPaths = () => (overlayReady() ? [persist.sitePackages] : []);
|
|
630
|
+
const ensurePrestartup = () => {
|
|
631
|
+
if (!overlayReady()) return null;
|
|
632
|
+
const r = pydepsMod.ensurePrestartupNode(io, { root, base });
|
|
633
|
+
if (r.status === 'created' || r.status === 'updated') info(`prestartup node ${r.dir}: ${r.status} — ComfyUI adds ${persist.sitePackages} before it imports the custom nodes`);
|
|
634
|
+
else if (r.status === 'foreign' || r.status === 'failed') warn(`prestartup node not written: ${r.reason}`);
|
|
635
|
+
return r;
|
|
636
|
+
};
|
|
637
|
+
out.prestartup = ensurePrestartup();
|
|
638
|
+
|
|
639
|
+
const check = nodeDeps.checkNodeDeps(io, { python: py.python, root, manifests, extraPaths: extraPaths() });
|
|
520
640
|
out.checked = true;
|
|
521
641
|
for (const e of check.errors) warn(`custom-node dependency check: ${e}`);
|
|
642
|
+
let needRestart = !!(out.prestartup && (out.prestartup.status === 'created' || out.prestartup.status === 'updated'));
|
|
643
|
+
let snapshotOf = null;
|
|
644
|
+
const dropSnap = () => { if (snapshotOf) overridesMod.dropSnapshot(io, snapshotOf); snapshotOf = null; };
|
|
522
645
|
if (check.nodes.length === 0) {
|
|
523
|
-
info(`custom-node dependencies satisfied in ${py.python} (ComfyUI pid ${instance.pid})`);
|
|
646
|
+
info(`custom-node dependencies satisfied in ${py.python}${overlayReady() ? ` (+ overlay ${persist.sitePackages})` : ''} (ComfyUI pid ${instance.pid})`);
|
|
524
647
|
if (interactive && restartAllowed === null) {
|
|
648
|
+
// Asked once and recorded: the unattended boot run must know it.
|
|
525
649
|
restartAllowed = await prompt.confirm(RESTART_PLATFORM_QUESTION, { defaultYes: true });
|
|
526
650
|
out.record.restartPlatformComfy = restartAllowed;
|
|
527
651
|
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
652
|
+
} else {
|
|
653
|
+
const what = nodeDeps.describeUnsatisfied(check.nodes);
|
|
654
|
+
info(`custom-node dependencies missing in ${py.python} (ComfyUI pid ${instance.pid}): ${what}`);
|
|
655
|
+
let install = boot || yes || !!flags['restart-platform-comfy'];
|
|
656
|
+
if (interactive && !install) {
|
|
657
|
+
const restartPart = restartAllowed === false ? '' : ` and restart the platform's ComfyUI (pid ${instance.pid}) so it loads them`;
|
|
658
|
+
install = await prompt.confirm(`Install the missing Python packages — ${what} — for ${py.python}${restartPart}?`, { defaultYes: true });
|
|
659
|
+
if (restartAllowed === null) {
|
|
660
|
+
restartAllowed = install;
|
|
661
|
+
out.record.restartPlatformComfy = install;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
if (!install) {
|
|
665
|
+
out.failed = true;
|
|
666
|
+
out.reason = `custom-node dependencies missing in the ComfyUI Python ${py.python}: ${what}`;
|
|
667
|
+
out.fix = `${tool} doctor --yes --restart-platform-comfy`;
|
|
668
|
+
return out;
|
|
669
|
+
}
|
|
670
|
+
if (persist.kind === 'overlay') {
|
|
671
|
+
persist = pydepsMod.planPersistence(io, { python: py.python, root, base, create: true });
|
|
672
|
+
if (persist.kind === 'overlay') {
|
|
673
|
+
const pr = ensurePrestartup();
|
|
674
|
+
if (pr && (pr.status === 'foreign' || pr.status === 'failed')) {
|
|
675
|
+
persist = { ...persist, kind: 'system', reason: pr.reason };
|
|
676
|
+
} else if (pr && !out.prestartup) out.prestartup = pr;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
if (persist.kind !== 'overlay') {
|
|
680
|
+
warn(`node dependencies go into ${py.python} itself (${persist.reason}) — they are lost with a node restart; \`${tool} boot\` reinstalls them`);
|
|
681
|
+
}
|
|
682
|
+
// Another profile on this ComfyUI (installer 0.2.6): a replacement it
|
|
683
|
+
// refuses must be undone — the overlay venv is copied aside first.
|
|
684
|
+
if (persist.kind === 'overlay' && overridesMod.profileIds([...(manifests || []), ...(otherManifests || [])]).length > 1) {
|
|
685
|
+
const snap = overridesMod.snapshotOverlay(io, persist.paths.dir);
|
|
686
|
+
if (snap.ok) snapshotOf = persist.paths.dir;
|
|
687
|
+
else warn(`overlay snapshot not taken (${snap.reason}) — a refused version replacement cannot be undone`);
|
|
688
|
+
}
|
|
689
|
+
const constraintsPath = statePath ? path.join(path.dirname(statePath), 'node-deps-constraints.txt') : null;
|
|
690
|
+
const inst = nodeDeps.installNodeDeps(io, {
|
|
691
|
+
python: py.python, nodes: check.nodes, torch: check.torch, constraintsPath, log: logger,
|
|
692
|
+
pipPython: persist.kind === 'overlay' ? persist.paths.python : null,
|
|
693
|
+
});
|
|
694
|
+
out.installed = inst.installed;
|
|
695
|
+
if (!inst.ok) {
|
|
696
|
+
dropSnap();
|
|
697
|
+
out.failed = true;
|
|
698
|
+
out.reason = inst.failed.map((f) => `${f.directory}: ${f.reason}`).join('; ');
|
|
699
|
+
out.fix = `fix the pip error above (network, disk space, a package conflict), then run: ${tool} doctor --yes --restart-platform-comfy`;
|
|
700
|
+
return out;
|
|
701
|
+
}
|
|
702
|
+
const again = nodeDeps.checkNodeDeps(io, { python: py.python, root, manifests, extraPaths: extraPaths() });
|
|
703
|
+
if (again.nodes.length > 0) {
|
|
704
|
+
dropSnap();
|
|
705
|
+
out.failed = true;
|
|
706
|
+
out.reason = `pip finished, but the requirements are still not satisfied in ${py.python}: ${nodeDeps.describeUnsatisfied(again.nodes)}`;
|
|
707
|
+
out.fix = `install them by hand: ${persist.kind === 'overlay' ? persist.paths.python : py.python} -m pip install -r <requirements.txt>, then run: ${tool} doctor --restart-platform-comfy`;
|
|
708
|
+
return out;
|
|
709
|
+
}
|
|
710
|
+
info(`custom-node dependencies installed: ${inst.installed.join(', ')} → ${persist.kind === 'overlay' ? persist.sitePackages : py.python}`);
|
|
711
|
+
needRestart = true;
|
|
712
|
+
}
|
|
713
|
+
out.persistence = { kind: persist.kind, base: persist.base, site_packages: persist.sitePackages || null, reason: persist.reason || null, python: py.python };
|
|
714
|
+
const prevDeps = (state && state.installer_options && state.installer_options.nodeDeps) || {};
|
|
715
|
+
let accepted = Array.isArray(prevDeps.accepted) ? prevDeps.accepted.slice() : [];
|
|
716
|
+
out.record.nodeDeps = { target: persist.kind, overlay: persist.sitePackages || null, python: py.python, overrides: [], accepted };
|
|
717
|
+
// Version replacements by the overlay (installer 0.2.6): logged, shown in
|
|
718
|
+
// RESULT, recorded; a replacement that touches another profile or the
|
|
719
|
+
// ComfyUI core needs consent.
|
|
720
|
+
if (overlayReady()) {
|
|
721
|
+
const ov = overridesStep(io, {
|
|
722
|
+
python: py.python, sitePackages: persist.sitePackages, root, manifests, otherManifests, info, warn,
|
|
723
|
+
});
|
|
724
|
+
if (ov) {
|
|
725
|
+
out.overrides = ov.overrides;
|
|
726
|
+
out.conflicts = ov.conflicts;
|
|
727
|
+
out.record.nodeDeps.overrides = ov.overrides.map(overridesMod.recordOf);
|
|
728
|
+
const pending = overridesMod.pendingConflicts(ov.conflicts, accepted);
|
|
729
|
+
if (pending.length > 0) {
|
|
730
|
+
const lines = pending.map(overridesMod.describeConflict);
|
|
731
|
+
for (const l of lines) warn(`version replacement affects another profile: ${l}`);
|
|
732
|
+
let consent = !!flags['accept-node-deps-overrides'];
|
|
733
|
+
if (!consent && interactive) {
|
|
734
|
+
consent = await prompt.confirm(`The node-deps overlay is first in sys.path of the whole ComfyUI. It replaces packages that another profile or ComfyUI itself uses:\n - ${lines.join('\n - ')}\nKeep these replacements (the other profile may stop working)?`, { defaultYes: false });
|
|
735
|
+
}
|
|
736
|
+
if (consent) {
|
|
737
|
+
const at = new Date(typeof io.now === 'function' ? io.now() : Date.now()).toISOString();
|
|
738
|
+
accepted = [...accepted, ...pending.map((c) => overridesMod.acceptedEntry(c, at))];
|
|
739
|
+
out.record.nodeDeps.accepted = accepted;
|
|
740
|
+
info(`version replacements accepted (${flags['accept-node-deps-overrides'] ? '--accept-node-deps-overrides' : 'answer'}): ${pending.map(overridesMod.conflictKey).join(', ')}`);
|
|
741
|
+
dropSnap();
|
|
742
|
+
} else {
|
|
743
|
+
let undone = '';
|
|
744
|
+
if (snapshotOf) {
|
|
745
|
+
const rs = overridesMod.restoreOverlay(io, snapshotOf);
|
|
746
|
+
snapshotOf = null;
|
|
747
|
+
if (rs.ok) {
|
|
748
|
+
undone = '; the overlay was restored to its state before this run';
|
|
749
|
+
info(`overlay ${persist.paths.dir} restored from the snapshot — the replacements were not kept`);
|
|
750
|
+
const back = overridesStep(io, { python: py.python, sitePackages: persist.sitePackages, root, manifests, otherManifests, info: () => {}, warn: () => {} });
|
|
751
|
+
out.record.nodeDeps.overrides = back ? back.overrides.map(overridesMod.recordOf) : [];
|
|
752
|
+
out.overrides = back ? back.overrides : [];
|
|
753
|
+
} else {
|
|
754
|
+
undone = `; restoring the overlay failed: ${rs.reason}`;
|
|
755
|
+
warn(rs.reason);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
out.failed = true;
|
|
759
|
+
const why = boot ? 'boot never consents' : (interactive ? 'not accepted' : 'no consent (--yes is not consent; use --accept-node-deps-overrides)');
|
|
760
|
+
out.reason = `the node-deps overlay would replace packages another profile on this ComfyUI uses (${why}): ${lines.join('; ')}${undone}. One GPU node — one profile`;
|
|
761
|
+
const profileArg = command === 'install' && Array.isArray(flags.profiles) && flags.profiles.length > 0 ? ` --profile ${flags.profiles.join(',')}` : '';
|
|
762
|
+
out.fix = `install this profile on a separate GPU node, or accept the replacements: ${tool} ${command === 'install' ? 'install' : 'doctor'}${profileArg} --accept-node-deps-overrides`;
|
|
763
|
+
return out;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
539
766
|
}
|
|
540
767
|
}
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
768
|
+
dropSnap();
|
|
769
|
+
// The running process imported the custom nodes at its start: the
|
|
770
|
+
// remedy for missing classes with the packages in place is a restart —
|
|
771
|
+
// decided by FACT (/object_info), not only by "installed just now":
|
|
772
|
+
// `doctor --restart-platform-comfy` must restart even when nothing was
|
|
773
|
+
// installed in this run (otherwise the printed fix loops).
|
|
774
|
+
const expectClasses = nodeDeps.profileNodeRequirements(io, { root, manifests }).flatMap((n) => n.classes);
|
|
775
|
+
if (expectClasses.length === 0) return out;
|
|
776
|
+
const have = instance.url ? await comfyuiMod.objectInfoClasses(io, instance.url) : null;
|
|
777
|
+
if (!have && !needRestart) return out; // not answering — the platform gate/verification reports it
|
|
778
|
+
const missingNow = have ? expectClasses.filter((c) => !have.has(c)) : expectClasses;
|
|
779
|
+
if (missingNow.length === 0) {
|
|
780
|
+
if (needRestart) info(`the running ComfyUI (pid ${instance.pid}) already has the node classes — no restart needed`);
|
|
546
781
|
return out;
|
|
547
782
|
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
783
|
+
if (!needRestart && decision.source !== 'flag') {
|
|
784
|
+
// A node that fails for another reason (syntax error, CUDA, …) is
|
|
785
|
+
// not fixed by restarting it on every boot: report the cause.
|
|
786
|
+
const diag = await nodeDeps.diagnoseMissingClasses(io, {
|
|
787
|
+
missingClasses: missingNow, manifests, root, url: instance.url, pid: instance.pid, python: py.python,
|
|
788
|
+
extraPaths: extraPaths(), logFiles: workerDir ? [path.join(path.dirname(path.resolve(workerDir)), 'logs', 'comfyui-restart.log')] : [],
|
|
789
|
+
});
|
|
790
|
+
if (diag.kind === 'import-failed') {
|
|
791
|
+
out.failed = true;
|
|
792
|
+
out.reason = `node classes missing: ${missingNow.join(', ')} — ${diag.detail}`;
|
|
793
|
+
out.fix = `fix the import error of the custom node (ComfyUI log: ${diag.log_source}), then run: ${tool} doctor --restart-platform-comfy`;
|
|
794
|
+
return out;
|
|
795
|
+
}
|
|
796
|
+
info(`node classes missing in the running ComfyUI (pid ${instance.pid}): ${missingNow.join(', ')} — ${diag.detail}`);
|
|
556
797
|
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
out.
|
|
560
|
-
out.reason = `pip finished, but the requirements are still not satisfied in ${py.python}: ${nodeDeps.describeUnsatisfied(again.nodes)}`;
|
|
561
|
-
out.fix = `${tool} doctor`;
|
|
562
|
-
return out;
|
|
798
|
+
if (restartAllowed === null && interactive) {
|
|
799
|
+
restartAllowed = await prompt.confirm(`The running ComfyUI (pid ${instance.pid}) loaded the custom nodes before their dependencies were in place. Restart it now (same command line, working directory and environment)?`, { defaultYes: true });
|
|
800
|
+
out.record.restartPlatformComfy = restartAllowed;
|
|
563
801
|
}
|
|
564
|
-
info(`custom-node dependencies installed: ${inst.installed.join(', ')}`);
|
|
565
802
|
if (restartAllowed !== true) {
|
|
566
803
|
// A ComfyUI that is not ours is never stopped without the option.
|
|
567
804
|
out.failed = true;
|
|
568
|
-
out.reason = `custom-node dependencies
|
|
805
|
+
out.reason = `custom-node dependencies are in place, but the platform's ComfyUI (pid ${instance.pid}) imported the nodes before that and was not restarted (restart of the platform's ComfyUI is off): ${missingNow.join(', ')} missing`;
|
|
569
806
|
out.fix = `restart the ComfyUI from the platform console, or run: ${tool} doctor --restart-platform-comfy`;
|
|
570
807
|
return out;
|
|
571
808
|
}
|
|
572
|
-
const
|
|
573
|
-
const rr = await nodeDeps.
|
|
574
|
-
pid: instance.pid, timeoutMs: waitMs, intervalMs, expectClasses, sleep, log: logger, onProgress: info, progressMs,
|
|
809
|
+
const restartLog = workerDir ? path.join(path.dirname(path.resolve(workerDir)), 'logs', 'comfyui-restart.log') : null;
|
|
810
|
+
const rr = await nodeDeps.restartForeignComfyUI(io, {
|
|
811
|
+
pid: instance.pid, timeoutMs: waitMs, intervalMs, expectClasses: missingNow, sleep, log: logger, onProgress: info, progressMs,
|
|
812
|
+
platformGraceMs, logFile: restartLog,
|
|
575
813
|
});
|
|
576
814
|
out.restarted = rr.stopped;
|
|
815
|
+
out.restart = { started_by: rr.started_by, log_file: rr.log_file };
|
|
577
816
|
if (!rr.ok) {
|
|
578
817
|
out.failed = true;
|
|
579
818
|
out.reason = rr.reason;
|
|
580
|
-
out.fix =
|
|
819
|
+
out.fix = rr.stopped
|
|
820
|
+
? `${rr.log_file ? `see ${rr.log_file}; ` : ''}when ComfyUI answers again, run: ${tool} doctor`
|
|
821
|
+
: `restart the ComfyUI from the platform console, then run: ${tool} doctor`;
|
|
581
822
|
if (rr.stopped) out.pid_changed = rr.pid != null;
|
|
823
|
+
if (rr.missing_classes && rr.missing_classes.length > 0 && rr.pid) {
|
|
824
|
+
const diag = await nodeDeps.diagnoseMissingClasses(io, {
|
|
825
|
+
missingClasses: rr.missing_classes, manifests, root, url: rr.url, pid: rr.pid, python: py.python,
|
|
826
|
+
extraPaths: extraPaths(), logFiles: [restartLog].filter(Boolean),
|
|
827
|
+
});
|
|
828
|
+
out.reason = `${rr.reason} — ${diag.detail}`;
|
|
829
|
+
if (diag.kind === 'import-failed') out.fix = `fix the import error of the custom node (log: ${diag.log_source}), then run: ${tool} doctor --restart-platform-comfy`;
|
|
830
|
+
}
|
|
582
831
|
return out;
|
|
583
832
|
}
|
|
584
|
-
|
|
833
|
+
const who = rr.started_by === 'installer' ? 'the installer started ComfyUI again (same command line, cwd and environment)' : 'the platform started ComfyUI again';
|
|
834
|
+
info(`${who}: pid ${rr.old_pid} → ${rr.pid} at ${rr.url} (after ${Math.round(rr.waited_ms / 1000)} s), node classes present`);
|
|
585
835
|
out.pid_changed = true;
|
|
586
836
|
out.instance = await comfyOwner.resolveComfyOwner(io, { state, root });
|
|
587
837
|
return out;
|
|
588
838
|
}
|
|
589
839
|
|
|
840
|
+
/** Owned paths created by the dependency gate (overlay venv base, prestartup node). */
|
|
841
|
+
function nodeDepsOwnedServices(gate) {
|
|
842
|
+
const out = [];
|
|
843
|
+
if (!gate || !gate.persistence || gate.persistence.kind !== 'overlay') return out;
|
|
844
|
+
if (gate.persistence.base) out.push({ id: 'node-deps-overlay', path: gate.persistence.base });
|
|
845
|
+
if (gate.prestartup && gate.prestartup.dir && gate.prestartup.status !== 'foreign' && gate.prestartup.status !== 'failed') {
|
|
846
|
+
out.push({ id: 'node-deps-prestartup-node', path: gate.prestartup.dir });
|
|
847
|
+
}
|
|
848
|
+
return out;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
/** Register owned service paths in an existing install-state.json (no-op without one). */
|
|
852
|
+
function recordOwnedServices(io, statePath, entries) {
|
|
853
|
+
if (!entries || entries.length === 0) return false;
|
|
854
|
+
const st = stateStore.loadState(io, statePath);
|
|
855
|
+
if (!st) return false;
|
|
856
|
+
for (const e of entries) stateStore.addOwnedComponent(st, 'services', e);
|
|
857
|
+
stateStore.saveState(io, statePath, st, io.now);
|
|
858
|
+
return true;
|
|
859
|
+
}
|
|
860
|
+
|
|
590
861
|
/** FAILED result of the dependency gate (the engine — worker start — does not run). */
|
|
591
862
|
function nodeDepsFailedResult({ gate, mode }) {
|
|
592
863
|
return {
|
|
@@ -603,6 +874,24 @@ function nodeDepsFailedResult({ gate, mode }) {
|
|
|
603
874
|
};
|
|
604
875
|
}
|
|
605
876
|
|
|
877
|
+
/**
|
|
878
|
+
* Register a file the installer wrote into the worker dir (uninstall removes
|
|
879
|
+
* it). Only for the recorded worker of THIS dir; no-op without a state.
|
|
880
|
+
*/
|
|
881
|
+
function recordWorkerFile(io, statePath, workerDir, file) {
|
|
882
|
+
try {
|
|
883
|
+
const st = stateStore.loadState(io, statePath);
|
|
884
|
+
const w = st && st.components && st.components.worker;
|
|
885
|
+
if (!w || !w.dir || path.resolve(w.dir) !== path.resolve(workerDir)) return false;
|
|
886
|
+
const files = new Set(w.files_installed || []);
|
|
887
|
+
if (files.has(file)) return false;
|
|
888
|
+
files.add(file);
|
|
889
|
+
w.files_installed = Array.from(files);
|
|
890
|
+
stateStore.saveState(io, statePath, st, io.now);
|
|
891
|
+
return true;
|
|
892
|
+
} catch (_) { return false; }
|
|
893
|
+
}
|
|
894
|
+
|
|
606
895
|
/** Store one installer option in install-state.json (a recorded answer). */
|
|
607
896
|
function recordInstallerOption(io, statePath, key, value) {
|
|
608
897
|
const st = stateStore.loadState(io, statePath);
|
|
@@ -680,6 +969,119 @@ function cmdBoot(flags, { io = createRealIo(), spawn = require('child_process').
|
|
|
680
969
|
}
|
|
681
970
|
}
|
|
682
971
|
|
|
972
|
+
/** This installer's version (package.json next to src/). */
|
|
973
|
+
function ownVersion() {
|
|
974
|
+
try { return require('../../package.json').version; } catch (_) { return null; }
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
/** Version of the persistent installer copy behind the `animastor` command (<base>/installer), or null. */
|
|
978
|
+
function installedToolsVersion(io, flags) {
|
|
979
|
+
const dir = path.join(path.dirname(resolveToolsDir(flags)), 'installer');
|
|
980
|
+
try { return JSON.parse(String(io.fs.readFileSync(path.join(dir, 'package.json'), 'utf8'))).version || null; } catch (_) { return null; }
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
/**
|
|
984
|
+
* Installer 0.2.5 — FIRST change of every install/doctor run, before any
|
|
985
|
+
* check that can end the run with ✗: the management tools (the `animastor`
|
|
986
|
+
* command and the persistent installer copy it runs) and an installed worker
|
|
987
|
+
* bundle are brought to THIS installer's version. Live E2E 02.11: 0.2.4
|
|
988
|
+
* stopped at the node-deps gate before its "install management tools" step,
|
|
989
|
+
* so ~/.local/bin/animastor stayed 0.2.3 (bundle 2.2.0) and the printed fix
|
|
990
|
+
* `animastor doctor --restart-platform-comfy` ran a version that did not
|
|
991
|
+
* know the flag. Every fix command printed afterwards names a command of
|
|
992
|
+
* THIS version — or the result says why it could not be updated.
|
|
993
|
+
* @returns {Promise<{ tools: object|null, tools_error: string|null, tools_skipped: string|null, bundle: object|null, version: string|null, tools_version: string|null }>}
|
|
994
|
+
*/
|
|
995
|
+
async function preflightSelfUpdate(io, {
|
|
996
|
+
flags, statePath, root, workerDir, hubUrl, repoRoot, manifests = [], logger = null, dryRun = false,
|
|
997
|
+
nodeBin = null, home = homeDir(), linkDir = undefined, cliPath = __filename,
|
|
998
|
+
installerSrcRoot = path.resolve(__dirname, '..', '..'),
|
|
999
|
+
} = {}) {
|
|
1000
|
+
const out = { tools: null, tools_error: null, tools_skipped: null, bundle: null, version: ownVersion(), tools_version: null };
|
|
1001
|
+
if (dryRun) { out.tools_skipped = 'dry-run'; return out; }
|
|
1002
|
+
const toolsDirEarly = resolveToolsDir(flags);
|
|
1003
|
+
// Never write as the wrong user (sudo vs. normal user): the host gate
|
|
1004
|
+
// later stops such a run with the full explanation.
|
|
1005
|
+
const own = prereq.checkOwnership(io, {
|
|
1006
|
+
paths: [root, workerDir, statePath, toolsDirEarly].filter(Boolean), home: prereq.currentHome(), currentUid: prereq.currentUid(),
|
|
1007
|
+
});
|
|
1008
|
+
if (!own.ok) { out.tools_skipped = 'ownership mismatch'; return out; }
|
|
1009
|
+
const wantTools = await resolveToolsDecision({ flags, prompt: null, prior: priorToolsDecision(io, statePath) });
|
|
1010
|
+
const toolsDir = toolsDirEarly;
|
|
1011
|
+
if (!wantTools) {
|
|
1012
|
+
out.tools_skipped = 'management tools declined (--no-tools)';
|
|
1013
|
+
} else {
|
|
1014
|
+
try {
|
|
1015
|
+
out.tools = management.installManagementTools(io, {
|
|
1016
|
+
toolsDir,
|
|
1017
|
+
nodePath: nodeBin || process.execPath,
|
|
1018
|
+
cliPath,
|
|
1019
|
+
installerSrcRoot,
|
|
1020
|
+
installerDestRoot: path.join(path.dirname(toolsDir), 'installer'),
|
|
1021
|
+
linkDir: linkDir !== undefined ? linkDir : management.defaultLinkDir(),
|
|
1022
|
+
home,
|
|
1023
|
+
statePath,
|
|
1024
|
+
root,
|
|
1025
|
+
workerDir,
|
|
1026
|
+
hubUrl,
|
|
1027
|
+
log: logger,
|
|
1028
|
+
platformAdapter: PLATFORM_ADAPTER,
|
|
1029
|
+
});
|
|
1030
|
+
} catch (err) {
|
|
1031
|
+
out.tools_error = err.message;
|
|
1032
|
+
if (logger) logger.warn(`management tools could not be updated: ${err.message}`);
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
out.tools_version = installedToolsVersion(io, flags);
|
|
1036
|
+
if (manifests.length > 0) {
|
|
1037
|
+
try {
|
|
1038
|
+
out.bundle = await engineMod.refreshInstalledWorkerBundle(io, {
|
|
1039
|
+
workerDir, manifest: manifests[0], repoRoot, hubUrl, log: logger, nodeBin,
|
|
1040
|
+
});
|
|
1041
|
+
} catch (err) {
|
|
1042
|
+
out.bundle = { status: 'failed', reason: err.message };
|
|
1043
|
+
}
|
|
1044
|
+
if (out.bundle && out.bundle.status === 'failed' && logger) logger.warn(`worker bundle ${out.bundle.have || '?'} could not be updated to ${out.bundle.want || '?'}: ${out.bundle.reason}`);
|
|
1045
|
+
// Installer 0.2.7: node-classes.json for the worker's readiness gate
|
|
1046
|
+
// — on install, bundle update, doctor and boot alike, so a node
|
|
1047
|
+
// installed by an older installer gets it on its next doctor/boot.
|
|
1048
|
+
try {
|
|
1049
|
+
out.node_classes = engineMod.writeNodeClasses(io, { workerDir, manifests, log: logger, version: ownVersion() });
|
|
1050
|
+
if (out.node_classes.status === 'written') recordWorkerFile(io, statePath, workerDir, 'node-classes.json');
|
|
1051
|
+
} catch (err) {
|
|
1052
|
+
out.node_classes = { status: 'failed', reason: err.message };
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
return out;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
/**
|
|
1059
|
+
* Result lines for a preflight that could not bring the tools/bundle to
|
|
1060
|
+
* this version — the fix commands of the result would otherwise run an
|
|
1061
|
+
* older `animastor` (or the worker an older bundle) without saying so.
|
|
1062
|
+
*/
|
|
1063
|
+
function preflightExtras(pre) {
|
|
1064
|
+
if (!pre) return [];
|
|
1065
|
+
const extra = [];
|
|
1066
|
+
if (!pre.tools_skipped && pre.version && pre.tools_version !== pre.version) {
|
|
1067
|
+
extra.push({
|
|
1068
|
+
ok: false,
|
|
1069
|
+
label: 'Management tools',
|
|
1070
|
+
detail: `the animastor command runs installer ${pre.tools_version || 'unknown'}, this installer is ${pre.version}${pre.tools_error ? ` — update failed: ${pre.tools_error}` : ''}; the fix commands of this result need ${pre.version}`,
|
|
1071
|
+
fix: 'run the install command from the Animastor setup page again',
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
1074
|
+
if (pre.bundle && pre.bundle.status === 'failed') {
|
|
1075
|
+
extra.push({
|
|
1076
|
+
ok: false,
|
|
1077
|
+
label: 'Worker bundle',
|
|
1078
|
+
detail: `installed ${pre.bundle.have || 'unknown'}, this installer ships ${pre.bundle.want || 'unknown'} — update failed: ${pre.bundle.reason}`,
|
|
1079
|
+
fix: 'run the install command from the Animastor setup page again',
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
return extra;
|
|
1083
|
+
}
|
|
1084
|
+
|
|
683
1085
|
/** The one line for the node startup script (printed at the end of an install). */
|
|
684
1086
|
function startupScriptLine(flags) {
|
|
685
1087
|
const tool = toolCommandPath(flags);
|
|
@@ -806,6 +1208,13 @@ async function cmdInstall(flags, { doctor = false } = {}) {
|
|
|
806
1208
|
const pathEntry = management.restoreCommandPath(realIo, { linkDir: management.defaultLinkDir(), home: homeDir() });
|
|
807
1209
|
if (!boot && pathEntry.updated.length > 0) console.log(`PATH block restored: ${pathEntry.updated.join(', ')}`);
|
|
808
1210
|
|
|
1211
|
+
// Tools + bundle of THIS version before anything can stop the run (0.2.5).
|
|
1212
|
+
const preflight = await preflightSelfUpdate(realIo, {
|
|
1213
|
+
flags, statePath, root, workerDir, hubUrl, repoRoot, manifests: loadedManifests, logger, dryRun,
|
|
1214
|
+
nodeBin: (probeMod.pickNodeBinary(realIo) || {}).bin || null,
|
|
1215
|
+
});
|
|
1216
|
+
const withPre = (res) => ({ ...res, preflight });
|
|
1217
|
+
|
|
809
1218
|
// Host packages that disappeared with the image restart (boot path).
|
|
810
1219
|
if (doctor) {
|
|
811
1220
|
const missingPkgs = missingRequiredHostPackages(realIo);
|
|
@@ -834,7 +1243,7 @@ async function cmdInstall(flags, { doctor = false } = {}) {
|
|
|
834
1243
|
instance = gate.instance;
|
|
835
1244
|
if (gate.waited && gate.waited.ok) runningComfy = probeMod.detectRunningComfyUI(realIo);
|
|
836
1245
|
if (gate.failed) {
|
|
837
|
-
printResult(platformComfyMissingResult({ waited: gate.waited, tool: toolCommandPath(flags), mode: 'existing' }), { flags, mode: 'existing', boot });
|
|
1246
|
+
printResult(withPre(platformComfyMissingResult({ waited: gate.waited, tool: toolCommandPath(flags), mode: 'existing' })), { flags, mode: 'existing', boot });
|
|
838
1247
|
process.exitCode = 1;
|
|
839
1248
|
prompt.close();
|
|
840
1249
|
return;
|
|
@@ -845,9 +1254,11 @@ async function cmdInstall(flags, { doctor = false } = {}) {
|
|
|
845
1254
|
// of the platform's main.py, reinstall, and (when allowed) let the
|
|
846
1255
|
// platform start its ComfyUI again so the node classes load.
|
|
847
1256
|
const recordedPid = priorState && priorState.comfy_owner ? priorState.comfy_owner.pid : null;
|
|
1257
|
+
const ownedServices = [];
|
|
848
1258
|
const depsGate = dryRun ? null : await platformNodeDepsGate(realIo, {
|
|
849
1259
|
instance, state: priorState, root, manifests: loadedManifests, flags, boot, yes, prompt,
|
|
850
|
-
waitMs: Math.max(
|
|
1260
|
+
waitMs: Math.max(180000, comfyWaitMs - (realIo.now() - windowStart)), logger, statePath, workerDir,
|
|
1261
|
+
otherManifests: otherProfileManifests(priorState, flags.profiles, { logger }), command: doctor ? 'doctor' : 'install',
|
|
851
1262
|
});
|
|
852
1263
|
if (depsGate) {
|
|
853
1264
|
instance = depsGate.instance;
|
|
@@ -855,8 +1266,11 @@ async function cmdInstall(flags, { doctor = false } = {}) {
|
|
|
855
1266
|
if (depsGate.record.restartPlatformComfy !== undefined) {
|
|
856
1267
|
recordInstallerOption(realIo, statePath, 'restartPlatformComfy', depsGate.record.restartPlatformComfy);
|
|
857
1268
|
}
|
|
1269
|
+
if (depsGate.record.nodeDeps) recordInstallerOption(realIo, statePath, 'nodeDeps', depsGate.record.nodeDeps);
|
|
1270
|
+
ownedServices.push(...nodeDepsOwnedServices(depsGate));
|
|
1271
|
+
recordOwnedServices(realIo, statePath, ownedServices);
|
|
858
1272
|
if (depsGate.failed) {
|
|
859
|
-
printResult(nodeDepsFailedResult({ gate: depsGate, mode: instance.mode }), { flags, mode: instance.mode, boot });
|
|
1273
|
+
printResult(withPre({ ...nodeDepsFailedResult({ gate: depsGate, mode: instance.mode }), node_deps_overrides: depsGate.overrides }), { flags, mode: instance.mode, boot });
|
|
860
1274
|
process.exitCode = 1;
|
|
861
1275
|
prompt.close();
|
|
862
1276
|
return;
|
|
@@ -971,7 +1385,7 @@ async function cmdInstall(flags, { doctor = false } = {}) {
|
|
|
971
1385
|
}
|
|
972
1386
|
|
|
973
1387
|
if (plan.blocked.length > 0) {
|
|
974
|
-
printFinal({ blocked: plan.blocked, tool: toolCommand(flags), mode });
|
|
1388
|
+
printFinal({ blocked: plan.blocked, tool: toolCommand(flags), mode, preflight });
|
|
975
1389
|
process.exitCode = 1;
|
|
976
1390
|
return;
|
|
977
1391
|
}
|
|
@@ -1116,7 +1530,7 @@ async function cmdInstall(flags, { doctor = false } = {}) {
|
|
|
1116
1530
|
process.exit(1);
|
|
1117
1531
|
}
|
|
1118
1532
|
if (plan2.blocked.length > 0) {
|
|
1119
|
-
printFinal({ blocked: plan2.blocked, tool: toolCommand(flags), mode });
|
|
1533
|
+
printFinal({ blocked: plan2.blocked, tool: toolCommand(flags), mode, preflight });
|
|
1120
1534
|
process.exitCode = 1;
|
|
1121
1535
|
return;
|
|
1122
1536
|
}
|
|
@@ -1135,13 +1549,15 @@ async function cmdInstall(flags, { doctor = false } = {}) {
|
|
|
1135
1549
|
comfyOwner: instance,
|
|
1136
1550
|
comfyWaitMs,
|
|
1137
1551
|
nodeClassesDeadline,
|
|
1552
|
+
ownedServices,
|
|
1553
|
+
bundleRefreshedEarly: !!(preflight.bundle && preflight.bundle.status === 'updated'),
|
|
1138
1554
|
restartPlatformComfy: restartPlatformComfyDecision(flags, priorState, { boot }).source === 'flag'
|
|
1139
1555
|
? !!flags['restart-platform-comfy']
|
|
1140
1556
|
: (depsGate && depsGate.record.restartPlatformComfy !== undefined ? depsGate.record.restartPlatformComfy : undefined),
|
|
1141
1557
|
hubVersion,
|
|
1142
1558
|
},
|
|
1143
1559
|
});
|
|
1144
|
-
printResult(result, { flags, mode, boot, hubVersion });
|
|
1560
|
+
printResult(withPre({ ...result, node_deps_overrides: depsGate ? depsGate.overrides : [] }), { flags, mode, boot, hubVersion });
|
|
1145
1561
|
} catch (err) {
|
|
1146
1562
|
if (err instanceof NoTerminalError) {
|
|
1147
1563
|
console.error('');
|
|
@@ -1169,6 +1585,12 @@ function installOptions(flags, { doctor = false } = {}) {
|
|
|
1169
1585
|
startWorker: flags['start-worker'] === true ? true
|
|
1170
1586
|
: flags['no-start-worker'] === true ? false
|
|
1171
1587
|
: (doctor ? true : undefined),
|
|
1588
|
+
// Installer 0.2.8: a running worker is restarted only for a changed
|
|
1589
|
+
// .env/bundle and never in the middle of a task (engine/worker
|
|
1590
|
+
// ensureWorker); the boot path only starts a stopped worker.
|
|
1591
|
+
waitJobMs: flags['wait-job-ms'] !== undefined && flags['wait-job-ms'] !== '' ? Number(flags['wait-job-ms']) : undefined,
|
|
1592
|
+
forceWorkerRestart: !!flags.force,
|
|
1593
|
+
boot: isBootRun(flags, doctor),
|
|
1172
1594
|
};
|
|
1173
1595
|
}
|
|
1174
1596
|
|
|
@@ -1396,7 +1818,9 @@ async function cmdVerify(flags) {
|
|
|
1396
1818
|
*/
|
|
1397
1819
|
/** Blocked steps + host remediation as summary items (shared by both outputs). */
|
|
1398
1820
|
function resultExtras(result, tool) {
|
|
1399
|
-
const extra =
|
|
1821
|
+
const extra = preflightExtras(result.preflight);
|
|
1822
|
+
// Version replacements of the node-deps overlay (installer 0.2.6).
|
|
1823
|
+
extra.push(...overridesMod.resultItems(result.node_deps_overrides));
|
|
1400
1824
|
for (const b of result.blocked || []) {
|
|
1401
1825
|
let fix = result.remediation && result.remediation.command ? `${result.remediation.command} && ${tool} doctor` : `${tool} doctor`;
|
|
1402
1826
|
if (/accept_runtime_change/.test(b.reason || '')) fix = `if ComfyUI already works, this can be ignored; to let the installer replace the runtime run: ${tool} doctor --accept-runtime-change`;
|
|
@@ -1430,7 +1854,8 @@ function printOneLineSummary(result, { flags = {}, mode = null } = {}) {
|
|
|
1430
1854
|
const what = [
|
|
1431
1855
|
`mode ${mode || result.mode}`,
|
|
1432
1856
|
owner && owner.url ? `ComfyUI ${owner.url}` : 'ComfyUI not reachable',
|
|
1433
|
-
worker && worker.started ? `worker pid ${worker.pid}` : 'worker not started',
|
|
1857
|
+
worker && worker.started ? `worker pid ${worker.pid}${worker.action === 'left' ? ' (left as is)' : ''}` : 'worker not started',
|
|
1858
|
+
`current job: ${currentJobOf(result, flags)}`,
|
|
1434
1859
|
].join(', ');
|
|
1435
1860
|
const head = summary.ok ? 'OK' : `FAILED — ${summary.failures.length} problem(s)`;
|
|
1436
1861
|
console.log(`animastor doctor: ${head} — ${what} (${tool})`);
|
|
@@ -1440,6 +1865,19 @@ function printOneLineSummary(result, { flags = {}, mode = null } = {}) {
|
|
|
1440
1865
|
}
|
|
1441
1866
|
}
|
|
1442
1867
|
|
|
1868
|
+
/** "none" | "<job_id>" | "unknown" — the worker's task at the end of the run (installer 0.2.8). */
|
|
1869
|
+
function currentJobOf(result, flags = {}) {
|
|
1870
|
+
const known = result && result.results && result.results.current_job;
|
|
1871
|
+
if (known) return known;
|
|
1872
|
+
// The engine did not run (e.g. the platform's ComfyUI never came up):
|
|
1873
|
+
// read the running worker's log directly.
|
|
1874
|
+
try {
|
|
1875
|
+
return workerMod.currentJobLabel(createRealIo(), { workerDir: resolveWorkerDir(flags), platformAdapter: PLATFORM_ADAPTER });
|
|
1876
|
+
} catch (_) {
|
|
1877
|
+
return 'unknown';
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1443
1881
|
function printResult(result, { flags = {}, mode = null, boot = false } = {}) {
|
|
1444
1882
|
if (boot) {
|
|
1445
1883
|
printOneLineSummary(result, { flags, mode });
|
|
@@ -1453,6 +1891,7 @@ function printResult(result, { flags = {}, mode = null, boot = false } = {}) {
|
|
|
1453
1891
|
const extra = resultExtras(result, tool);
|
|
1454
1892
|
const summary = renderFinalSummary({ verification: result.verification, e2e: result.e2e || [], extra, tool, mode: mode || result.mode });
|
|
1455
1893
|
console.log(summary.text);
|
|
1894
|
+
console.log(`current job: ${currentJobOf(result, flags)}`);
|
|
1456
1895
|
// The full path is printed even when ~/.local/bin is already in PATH:
|
|
1457
1896
|
// after a node reboot the PATH block is gone, and a copy-pasted relative
|
|
1458
1897
|
// `animastor` must not be the only way to run the command.
|
|
@@ -1465,8 +1904,8 @@ function printResult(result, { flags = {}, mode = null, boot = false } = {}) {
|
|
|
1465
1904
|
}
|
|
1466
1905
|
|
|
1467
1906
|
/** Result block for a plan that is blocked before anything ran. */
|
|
1468
|
-
function printFinal({ blocked = [], tool = 'animastor', mode = null }) {
|
|
1469
|
-
const extra = blocked.map((b) => ({ ok: false, label: `Step "${b.step || b.id || 'plan'}"`, detail: b.reason, fix: `${tool} doctor` }));
|
|
1907
|
+
function printFinal({ blocked = [], tool = 'animastor', mode = null, preflight = null }) {
|
|
1908
|
+
const extra = [...preflightExtras(preflight), ...blocked.map((b) => ({ ok: false, label: `Step "${b.step || b.id || 'plan'}"`, detail: b.reason, fix: `${tool} doctor` }))];
|
|
1470
1909
|
console.log(renderFinalSummary({ extra, tool, mode }).text);
|
|
1471
1910
|
}
|
|
1472
1911
|
|
|
@@ -1725,7 +2164,11 @@ async function cmdStart(flags) {
|
|
|
1725
2164
|
if (stats) {
|
|
1726
2165
|
start = workerMod.startWorker(io, { workerDir: targets.workerDir });
|
|
1727
2166
|
if (start.started && start.alive) {
|
|
1728
|
-
if (start.already_running)
|
|
2167
|
+
if (start.already_running) {
|
|
2168
|
+
screen.print(start.busy_job
|
|
2169
|
+
? `worker already running (pid ${start.pid}), busy with ${start.busy_job} — its .env changed, restart deferred until the task finishes (run \`${toolCommand(flags)} doctor\`)`
|
|
2170
|
+
: `worker already running (pid ${start.pid})`);
|
|
2171
|
+
}
|
|
1729
2172
|
ready = await screen.withBusy('Waiting for the worker (ComfyUI ready → hub heartbeat)', () => workerMod.waitForWorkerReady(io, {
|
|
1730
2173
|
workerDir: targets.workerDir, pid: start.pid, logFile: start.logFile, logOffset: start.logOffset || 0,
|
|
1731
2174
|
}));
|
|
@@ -1792,6 +2235,14 @@ async function cmdDoctor(flags) {
|
|
|
1792
2235
|
async function main() {
|
|
1793
2236
|
const args = parseArgs(process.argv);
|
|
1794
2237
|
const pkg = require('../../package.json');
|
|
2238
|
+
// A command line this version does not understand is never "best
|
|
2239
|
+
// effort": an ignored option silently changes what the run does.
|
|
2240
|
+
if (args.errors.length > 0) {
|
|
2241
|
+
for (const e of args.errors) console.error(`animastor-installer ${pkg.version}: ${e}`);
|
|
2242
|
+
console.error(`Run with --help for the list of commands and options (this is installer ${pkg.version}).`);
|
|
2243
|
+
process.exit(USAGE_EXIT);
|
|
2244
|
+
}
|
|
2245
|
+
if (args.flags.help) args.command = null;
|
|
1795
2246
|
// install/doctor print the full banner; the everyday tool commands stay quiet.
|
|
1796
2247
|
if (!['install', 'doctor', 'start', 'stop', 'logs', 'status', 'boot'].includes(args.command)) {
|
|
1797
2248
|
console.log(`animastor-installer v${pkg.version} (platform: ${PLATFORM_RUNTIME.platform}, deployment: ${PLATFORM_RUNTIME.deployment})`);
|
|
@@ -1859,16 +2310,17 @@ async function main() {
|
|
|
1859
2310
|
console.error(' a free port when 8188 is taken; opt out:');
|
|
1860
2311
|
console.error(' --no-start-comfy --no-start-worker --comfy-port N');
|
|
1861
2312
|
console.error(' management (the `animastor` command in PATH):');
|
|
1862
|
-
console.error(' animastor start | stop | status | logs [-f] | doctor [--new-key] | boot');
|
|
2313
|
+
console.error(' animastor start | stop | status | logs [-f] | doctor [--new-key] [--wait-job-ms N] [--force] | boot');
|
|
1863
2314
|
console.error(' boot: node startup script — detaches `doctor --yes` (log ~/animastor/logs/bootstrap.log), exits 0');
|
|
1864
2315
|
console.error(' --restart-platform-comfy / --no-restart-platform-comfy restart the platform ComfyUI after node deps');
|
|
2316
|
+
console.error(' --accept-node-deps-overrides consent: the node-deps overlay may replace a package another profile / ComfyUI core uses');
|
|
1865
2317
|
console.error(' (also: monitor | reboot-worker | reboot-comfyui)');
|
|
1866
2318
|
console.error(' (--state/--root/--worker-dir/--port override discovery)');
|
|
1867
2319
|
console.error(' installer flags: --install-tools / --no-tools / --tools-dir PATH');
|
|
1868
2320
|
console.error(' uninstall flags:');
|
|
1869
2321
|
console.error(' --all Full uninstall (remove everything recorded as installed by Animastor)');
|
|
1870
2322
|
console.error(' --state PATH Install state file path');
|
|
1871
|
-
process.exit(1);
|
|
2323
|
+
process.exit(args.flags.help ? 0 : 1);
|
|
1872
2324
|
}
|
|
1873
2325
|
}
|
|
1874
2326
|
|
|
@@ -1880,7 +2332,7 @@ if (require.main === module) {
|
|
|
1880
2332
|
}
|
|
1881
2333
|
|
|
1882
2334
|
module.exports = {
|
|
1883
|
-
stepQuestion, parseArgs, cmdDetect, cmdPlan, cmdInstall, cmdStart, cmdStop, cmdLogs, cmdDoctor,
|
|
2335
|
+
stepQuestion, parseArgs, BOOLEAN_FLAGS, VALUE_FLAGS, COMMANDS, USAGE_EXIT, cmdDetect, cmdPlan, cmdInstall, cmdStart, cmdStop, cmdLogs, cmdDoctor,
|
|
1884
2336
|
printResult, printOneLineSummary, resultExtras, cmdVerify, cmdValidateManifests, cmdResume,
|
|
1885
2337
|
cmdUninstall, cmdStatus, cmdMonitor, cmdRebootWorker, cmdRebootComfyUI, resolveAndPlan,
|
|
1886
2338
|
makeSecretProvider, resolveToolsDecision, resolveToolsDir, installOptions, runHostGates,
|
|
@@ -1889,4 +2341,6 @@ module.exports = {
|
|
|
1889
2341
|
missingRequiredHostPackages, shouldWaitForPlatformComfy, platformComfyGate, platformComfyMissingResult,
|
|
1890
2342
|
restartPlatformComfyDecision, platformNodeDepsGate, nodeDepsFailedResult, recordInstallerOption,
|
|
1891
2343
|
cmdBoot, bootChildArgs, bootLogPath, startupScriptLine,
|
|
2344
|
+
preflightSelfUpdate, preflightExtras, installedToolsVersion, ownVersion,
|
|
2345
|
+
nodeDepsOwnedServices, recordOwnedServices, otherProfileManifests, overridesStep,
|
|
1892
2346
|
};
|