@zixt/host 0.0.86 → 0.0.87
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/dist/index.js +57 -27
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7,9 +7,6 @@ var __export = (target, all) => {
|
|
|
7
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
// src/index.ts
|
|
11
|
-
import { fstatSync as fstatSync2 } from "node:fs";
|
|
12
|
-
|
|
13
10
|
// src/supervisor.ts
|
|
14
11
|
import { spawn as spawn5 } from "node:child_process";
|
|
15
12
|
import { fstatSync } from "node:fs";
|
|
@@ -31,7 +28,7 @@ import { homedir as homedir3 } from "node:os";
|
|
|
31
28
|
// package.json
|
|
32
29
|
var package_default = {
|
|
33
30
|
name: "@zixt/host",
|
|
34
|
-
version: "0.0.
|
|
31
|
+
version: "0.0.87",
|
|
35
32
|
type: "module",
|
|
36
33
|
exports: {
|
|
37
34
|
".": "./src/client.ts",
|
|
@@ -26466,15 +26463,15 @@ async function launchHostSupervisor(options = {}) {
|
|
|
26466
26463
|
const onTerm = () => stop("SIGTERM");
|
|
26467
26464
|
process.on("SIGINT", onInt);
|
|
26468
26465
|
process.on("SIGTERM", onTerm);
|
|
26469
|
-
let
|
|
26466
|
+
let stdinIsPipe = options.parentStdinIsPipe ?? false;
|
|
26470
26467
|
if (options.parentStdinIsPipe === void 0) {
|
|
26471
26468
|
try {
|
|
26472
26469
|
const stat3 = fstatSync(0);
|
|
26473
|
-
|
|
26470
|
+
stdinIsPipe = !stat3.isCharacterDevice() && !stat3.isFile() && !process.stdin.isTTY;
|
|
26474
26471
|
} catch {
|
|
26475
26472
|
}
|
|
26476
26473
|
}
|
|
26477
|
-
const observesParentStdin = managedLifecycle &&
|
|
26474
|
+
const observesParentStdin = managedLifecycle && stdinIsPipe;
|
|
26478
26475
|
const onStdinEnd = () => stop("SIGTERM");
|
|
26479
26476
|
const onStdinError = () => stop("SIGTERM");
|
|
26480
26477
|
const onStdinData = (chunk) => {
|
|
@@ -27101,9 +27098,14 @@ async function superviseHost(options = {}) {
|
|
|
27101
27098
|
"Zixt Host: a newer release was reported but the registry is unreachable; staying on the current version"
|
|
27102
27099
|
);
|
|
27103
27100
|
} else if (target === command.version) {
|
|
27104
|
-
|
|
27105
|
-
|
|
27106
|
-
|
|
27101
|
+
if (unsatisfiableUpdates === 0) {
|
|
27102
|
+
log2(
|
|
27103
|
+
`Zixt Host: ${target} is the newest published Zixt Host, so no update can satisfy this cloud; the cloud this Machine is paired to speaks a newer Host protocol than any published release`
|
|
27104
|
+
);
|
|
27105
|
+
log2(
|
|
27106
|
+
"Zixt Host: pair this Machine with a cloud running a published release, or start the Host from the same source checkout that cloud runs; this Machine connects by itself once a matching release is published"
|
|
27107
|
+
);
|
|
27108
|
+
}
|
|
27107
27109
|
} else if (attempted.has(target)) {
|
|
27108
27110
|
log2(`Zixt Host: already running ${target}; ignoring a repeated update request`);
|
|
27109
27111
|
} else {
|
|
@@ -27271,6 +27273,38 @@ function beginWorkerShutdown(options) {
|
|
|
27271
27273
|
});
|
|
27272
27274
|
}
|
|
27273
27275
|
|
|
27276
|
+
// src/parent-pipe.ts
|
|
27277
|
+
import { fstatSync as fstatSync2 } from "node:fs";
|
|
27278
|
+
var END_OF_TEXT = 3;
|
|
27279
|
+
function stdinIsParentPipe(stat3 = (fd) => fstatSync2(fd), isTTY = process.stdin.isTTY === true) {
|
|
27280
|
+
try {
|
|
27281
|
+
const stdin = stat3(0);
|
|
27282
|
+
return !stdin.isCharacterDevice() && !stdin.isFile() && !isTTY;
|
|
27283
|
+
} catch {
|
|
27284
|
+
return false;
|
|
27285
|
+
}
|
|
27286
|
+
}
|
|
27287
|
+
function watchParentPipe(pipe2, onStop) {
|
|
27288
|
+
const stop = () => onStop();
|
|
27289
|
+
const onData = (chunk) => {
|
|
27290
|
+
if (chunk.includes(END_OF_TEXT)) onStop();
|
|
27291
|
+
};
|
|
27292
|
+
pipe2.on("end", stop);
|
|
27293
|
+
pipe2.on("error", stop);
|
|
27294
|
+
pipe2.on("data", onData);
|
|
27295
|
+
pipe2.resume();
|
|
27296
|
+
let released = false;
|
|
27297
|
+
return () => {
|
|
27298
|
+
if (released) return;
|
|
27299
|
+
released = true;
|
|
27300
|
+
pipe2.off("end", stop);
|
|
27301
|
+
pipe2.off("error", stop);
|
|
27302
|
+
pipe2.off("data", onData);
|
|
27303
|
+
pipe2.pause();
|
|
27304
|
+
pipe2.unref?.();
|
|
27305
|
+
};
|
|
27306
|
+
}
|
|
27307
|
+
|
|
27274
27308
|
// src/index.ts
|
|
27275
27309
|
import { homedir as homedir14, hostname as hostname3 } from "node:os";
|
|
27276
27310
|
|
|
@@ -40792,6 +40826,8 @@ var connectionContext = connectionLogContext({
|
|
|
40792
40826
|
});
|
|
40793
40827
|
var stopUpdateWatch = () => {
|
|
40794
40828
|
};
|
|
40829
|
+
var releaseParentPipeWatch = () => {
|
|
40830
|
+
};
|
|
40795
40831
|
var updateRestartGate = createIdleUpdateRestartGate({
|
|
40796
40832
|
activeTasks: () => activeSessions,
|
|
40797
40833
|
deferred: (version2, activeTasks) => {
|
|
@@ -40940,9 +40976,10 @@ var client = new HostClient({
|
|
|
40940
40976
|
queueMicrotask(() => shutdown(DO_NOT_RESTART_EXIT_CODE));
|
|
40941
40977
|
break;
|
|
40942
40978
|
case "incompatible":
|
|
40943
|
-
log.error("Host
|
|
40979
|
+
log.error("Zixt Cloud refused this Host as too old to connect", {
|
|
40944
40980
|
...connectionContext,
|
|
40945
|
-
|
|
40981
|
+
protocol: PROTOCOL_VERSION,
|
|
40982
|
+
next: packagedBuild ? "Zixt checks the published release now; nothing to do on this Machine" : "Update this checkout through Git and restart the Host"
|
|
40946
40983
|
});
|
|
40947
40984
|
queueMicrotask(() => shutdown(packagedBuild ? UPDATE_EXIT_CODE : DO_NOT_RESTART_EXIT_CODE));
|
|
40948
40985
|
break;
|
|
@@ -40964,7 +41001,7 @@ var diagnosticsRoot = configuredWorkerDiagnosticsRoot();
|
|
|
40964
41001
|
var reportedWorkerExits = diagnosticsRoot ? await readWorkerExits(diagnosticsRoot) : [];
|
|
40965
41002
|
for (const { record: record2 } of reportedWorkerExits) {
|
|
40966
41003
|
const { summary, context } = describeWorkerExit(record2);
|
|
40967
|
-
|
|
41004
|
+
replayConsoleLine("error", `The previous Zixt Host worker ${summary}`, {
|
|
40968
41005
|
machine,
|
|
40969
41006
|
at: record2.at,
|
|
40970
41007
|
...context,
|
|
@@ -40988,7 +41025,11 @@ function shutdown(exitCode = 0) {
|
|
|
40988
41025
|
beginWorkerShutdown({
|
|
40989
41026
|
activeTasks: activeSessions,
|
|
40990
41027
|
exitCode,
|
|
40991
|
-
teardown: () =>
|
|
41028
|
+
teardown: async () => {
|
|
41029
|
+
await client.stop();
|
|
41030
|
+
releaseParentPipeWatch();
|
|
41031
|
+
stopUpdateWatch();
|
|
41032
|
+
},
|
|
40992
41033
|
stopHeartbeat: () => workerWatchdog.stop(),
|
|
40993
41034
|
onForcedExit: ({ deadlineMs, code, teardownCompleted }) => {
|
|
40994
41035
|
log.warn(
|
|
@@ -41025,17 +41066,6 @@ stopUpdateWatch = !packagedBuild ? () => {
|
|
|
41025
41066
|
});
|
|
41026
41067
|
process.on("SIGINT", () => shutdown());
|
|
41027
41068
|
process.on("SIGTERM", () => shutdown());
|
|
41028
|
-
|
|
41029
|
-
|
|
41030
|
-
const stat3 = fstatSync2(0);
|
|
41031
|
-
stdinIsPipe = !stat3.isCharacterDevice() && !stat3.isFile() && !process.stdin.isTTY;
|
|
41032
|
-
} catch {
|
|
41033
|
-
}
|
|
41034
|
-
if (stdinIsPipe) {
|
|
41035
|
-
process.stdin.on("end", () => shutdown());
|
|
41036
|
-
process.stdin.on("error", () => shutdown());
|
|
41037
|
-
process.stdin.on("data", (chunk) => {
|
|
41038
|
-
if (chunk.includes(3)) shutdown();
|
|
41039
|
-
});
|
|
41040
|
-
process.stdin.resume();
|
|
41069
|
+
if (stdinIsParentPipe()) {
|
|
41070
|
+
releaseParentPipeWatch = watchParentPipe(process.stdin, () => shutdown());
|
|
41041
41071
|
}
|