@ddtcorex/dsh-maestro-supervisor 0.7.9 → 0.7.10
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/lib/restart-tool.d.ts +10 -0
- package/lib/restart-tool.js +35 -3
- package/package.json +1 -1
package/lib/restart-tool.d.ts
CHANGED
|
@@ -13,6 +13,16 @@
|
|
|
13
13
|
* (out-of-band). This tool NEVER restarts the host in-tree.
|
|
14
14
|
*/
|
|
15
15
|
import { writeRestartRequest } from './restart-guards.js';
|
|
16
|
+
/**
|
|
17
|
+
* Copy a live profile tree for an isolated dry-boot. A naive recursive copy
|
|
18
|
+
* breaks `link:` installs: their node_modules entries are relative symlinks
|
|
19
|
+
* (e.g. `../../../shared/pkg`) that resolve against the copy location and
|
|
20
|
+
* dangle. Every symlink left dangling by the copy is rewritten to the
|
|
21
|
+
* absolute live target it pointed at, so the dry-boot loads the same code
|
|
22
|
+
* the live tree loads. Links already broken in the live tree are left alone
|
|
23
|
+
* (the dry-boot must stay faithful, not fix the live tree).
|
|
24
|
+
*/
|
|
25
|
+
export declare function copyProfileForDryBoot(srcDir: string, destDir: string): void;
|
|
16
26
|
/**
|
|
17
27
|
* Boot a copy of the live web profile on an isolated DSH_HOME and verify the
|
|
18
28
|
* plugin tree loads and serves. Returns ok + a one-line detail for the tool
|
package/lib/restart-tool.js
CHANGED
|
@@ -12,12 +12,44 @@
|
|
|
12
12
|
* callerSessionId) that the supervisor daemon owns and acts on
|
|
13
13
|
* (out-of-band). This tool NEVER restarts the host in-tree.
|
|
14
14
|
*/
|
|
15
|
-
import { join } from 'node:path';
|
|
16
|
-
import { mkdtempSync, rmSync, cpSync, existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
|
|
15
|
+
import { join, dirname, resolve } from 'node:path';
|
|
16
|
+
import { mkdtempSync, rmSync, cpSync, existsSync, readFileSync, readdirSync, statSync, lstatSync, readlinkSync, symlinkSync, unlinkSync } from 'node:fs';
|
|
17
17
|
import { tmpdir, homedir } from 'node:os';
|
|
18
18
|
import { spawn } from 'node:child_process';
|
|
19
19
|
import { createRequire } from 'node:module';
|
|
20
20
|
import { writeRestartRequest } from './restart-guards.js';
|
|
21
|
+
/**
|
|
22
|
+
* Copy a live profile tree for an isolated dry-boot. A naive recursive copy
|
|
23
|
+
* breaks `link:` installs: their node_modules entries are relative symlinks
|
|
24
|
+
* (e.g. `../../../shared/pkg`) that resolve against the copy location and
|
|
25
|
+
* dangle. Every symlink left dangling by the copy is rewritten to the
|
|
26
|
+
* absolute live target it pointed at, so the dry-boot loads the same code
|
|
27
|
+
* the live tree loads. Links already broken in the live tree are left alone
|
|
28
|
+
* (the dry-boot must stay faithful, not fix the live tree).
|
|
29
|
+
*/
|
|
30
|
+
export function copyProfileForDryBoot(srcDir, destDir) {
|
|
31
|
+
cpSync(srcDir, destDir, { recursive: true, preserveTimestamps: true });
|
|
32
|
+
const repair = (dir, rel) => {
|
|
33
|
+
for (const name of readdirSync(dir)) {
|
|
34
|
+
const p = join(dir, name);
|
|
35
|
+
const r = rel ? `${rel}/${name}` : name;
|
|
36
|
+
const st = lstatSync(p);
|
|
37
|
+
if (st.isSymbolicLink()) {
|
|
38
|
+
if (!existsSync(p)) {
|
|
39
|
+
const liveTarget = resolve(srcDir, dirname(r), readlinkSync(p));
|
|
40
|
+
if (existsSync(liveTarget)) {
|
|
41
|
+
unlinkSync(p);
|
|
42
|
+
symlinkSync(liveTarget, p);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else if (st.isDirectory()) {
|
|
47
|
+
repair(p, r);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
repair(destDir, '');
|
|
52
|
+
}
|
|
21
53
|
/**
|
|
22
54
|
* Boot a copy of the live web profile on an isolated DSH_HOME and verify the
|
|
23
55
|
* plugin tree loads and serves. Returns ok + a one-line detail for the tool
|
|
@@ -39,7 +71,7 @@ export async function dryBootVerify(harnessRoot, opts = {}) {
|
|
|
39
71
|
const logs = [];
|
|
40
72
|
let child = null;
|
|
41
73
|
try {
|
|
42
|
-
|
|
74
|
+
copyProfileForDryBoot(liveProfile, join(tmpHome, 'profiles', 'web'));
|
|
43
75
|
const port = String(9000 + Math.floor(Math.random() * 1000));
|
|
44
76
|
const url = `http://127.0.0.1:${port}/`;
|
|
45
77
|
child = spawn('node', ['--import', 'tsx/esm', 'apps/cli/src/bin.ts', 'web', '--no-open', '--port', port], {
|
package/package.json
CHANGED