witnora 0.20.10 → 0.20.11
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/cli.js +7 -3
- package/dist/gateway-service.js +11 -3
- package/dist/gateway.js +13 -6
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -40,8 +40,8 @@ import { runOnboard } from "./onboard.js";
|
|
|
40
40
|
import { inspectRepository } from "./onboard.js";
|
|
41
41
|
import { renderReleaseEvaluation, runReleaseEvaluation } from "./release-evaluation.js";
|
|
42
42
|
import { runPrivateCapabilityDiscovery } from "./private-discovery.js";
|
|
43
|
-
import { configureManagedWorkflowHarness, doctorCustomerGateway, initializeCustomerGateway, isGatewayDoctorReady, readManagedCustomerGatewayLogs, renderGatewayDoctor, renderManagedGatewayStatus,
|
|
44
|
-
import { installCurrentGatewayService, stopCurrentGatewayOwners, uninstallCurrentGatewayService } from "./gateway-service.js";
|
|
43
|
+
import { awaitManagedCustomerGateway, configureManagedWorkflowHarness, doctorCustomerGateway, initializeCustomerGateway, isGatewayDoctorReady, readManagedCustomerGatewayLogs, renderGatewayDoctor, renderManagedGatewayStatus, runCustomerGateway, startManagedCustomerGateway, statusManagedCustomerGateway, stopManagedCustomerGateway, superviseManagedCustomerGateway, } from "./gateway.js";
|
|
44
|
+
import { installCurrentGatewayService, restartCurrentGatewayOwners, stopCurrentGatewayOwners, uninstallCurrentGatewayService } from "./gateway-service.js";
|
|
45
45
|
import { runCustomerGatewayCommand } from "./gateway-exec.js";
|
|
46
46
|
import { verifyEvidencePacketV02 } from "./evidence-v02.js";
|
|
47
47
|
process.on("uncaughtException", reportFatalError);
|
|
@@ -234,7 +234,11 @@ else if (command === "gateway") {
|
|
|
234
234
|
process.stdout.write(`${await readManagedCustomerGatewayLogs({ repository: readFlag("--repo") ?? process.cwd(), dir: readFlag("--dir"), lines })}\n`);
|
|
235
235
|
}
|
|
236
236
|
else if (action === "restart") {
|
|
237
|
-
const
|
|
237
|
+
const repository = readFlag("--repo") ?? process.cwd();
|
|
238
|
+
const dir = readFlag("--dir");
|
|
239
|
+
const configHome = readFlag("--config-home");
|
|
240
|
+
const serviceOptions = { repository, gatewayDirectory: dir, cliEntry: fileURLToPath(import.meta.url), configHome };
|
|
241
|
+
const result = await restartCurrentGatewayOwners(serviceOptions, () => stopManagedCustomerGateway({ repository, dir, configHome }), () => awaitManagedCustomerGateway({ repository, dir, configHome }));
|
|
238
242
|
process.stdout.write(readBoolFlag("--json") ? `${JSON.stringify(result, null, 2)}\n` : renderManagedGatewayStatus(result));
|
|
239
243
|
}
|
|
240
244
|
else if (action === "repair") {
|
package/dist/gateway-service.js
CHANGED
|
@@ -12,9 +12,11 @@ export async function installGatewayService(input) {
|
|
|
12
12
|
// before replacing the definition so onboarding never leaves two owners
|
|
13
13
|
// racing for the same localhost port.
|
|
14
14
|
if (plan.kind === "WINDOWS_TASK") {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
if (!input.existingOwnerStopped) {
|
|
16
|
+
await input.run(plan.stop.command, plan.stop.args).catch(() => undefined);
|
|
17
|
+
await (input.removeFile ?? removeFile)(plan.serviceLease.path);
|
|
18
|
+
await (input.sleep ?? wait)(WINDOWS_PARENT_EXIT_GRACE_MS);
|
|
19
|
+
}
|
|
18
20
|
await input.writeDefinition(plan.serviceLease.path, `${plan.serviceLease.generation}\n`);
|
|
19
21
|
}
|
|
20
22
|
if (plan.launcher)
|
|
@@ -40,6 +42,7 @@ export async function installCurrentGatewayService(options) {
|
|
|
40
42
|
run: options.run ?? runCommand,
|
|
41
43
|
sleep: options.sleep,
|
|
42
44
|
removeFile: options.removeFile,
|
|
45
|
+
existingOwnerStopped: options.existingOwnerStopped,
|
|
43
46
|
});
|
|
44
47
|
}
|
|
45
48
|
export async function uninstallCurrentGatewayService(options) {
|
|
@@ -69,6 +72,11 @@ export async function restartCurrentGatewayService(options) {
|
|
|
69
72
|
await run(plan.start.command, plan.start.args);
|
|
70
73
|
return plan;
|
|
71
74
|
}
|
|
75
|
+
export async function restartCurrentGatewayOwners(options, stopManagedGateway, awaitManagedGateway) {
|
|
76
|
+
await stopCurrentGatewayOwners(options, stopManagedGateway);
|
|
77
|
+
await restartCurrentGatewayService({ ...options, existingOwnerStopped: true });
|
|
78
|
+
return awaitManagedGateway();
|
|
79
|
+
}
|
|
72
80
|
export async function stopCurrentGatewayService(options) {
|
|
73
81
|
const plan = createGatewayServicePlan(currentPlanInput(options));
|
|
74
82
|
await (options.run ?? runCommand)(plan.stop.command, plan.stop.args).catch(() => undefined);
|
package/dist/gateway.js
CHANGED
|
@@ -1424,12 +1424,19 @@ export async function stopManagedCustomerGateway(options = {}) {
|
|
|
1424
1424
|
const after = await statusManagedCustomerGateway(options);
|
|
1425
1425
|
return { ...after, stopped: !after.healthy };
|
|
1426
1426
|
}
|
|
1427
|
-
export async function
|
|
1428
|
-
const
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1427
|
+
export async function awaitManagedCustomerGateway(options = {}) {
|
|
1428
|
+
const sleep = options.sleep ?? wait;
|
|
1429
|
+
const deadline = Date.now() + (options.timeoutMs ?? 12_000);
|
|
1430
|
+
let status = await statusManagedCustomerGateway(options);
|
|
1431
|
+
while (Date.now() < deadline) {
|
|
1432
|
+
if (status.state === "RUNNING_MANAGED")
|
|
1433
|
+
return { ...status, started: true };
|
|
1434
|
+
if (status.state === "RUNNING_EXTERNAL" || status.state === "CONFLICT")
|
|
1435
|
+
throw new Error(status.detail);
|
|
1436
|
+
await sleep(120);
|
|
1437
|
+
status = await statusManagedCustomerGateway(options);
|
|
1438
|
+
}
|
|
1439
|
+
throw new Error(`The operating-system Gateway supervisor did not restore a healthy managed process before the startup deadline. ${status.detail}`);
|
|
1433
1440
|
}
|
|
1434
1441
|
export async function superviseManagedCustomerGateway(options = {}) {
|
|
1435
1442
|
const inspect = options.inspect ?? (() => statusManagedCustomerGateway({ repository: options.repository, dir: options.dir }));
|