@delt/claude-alarm 1.4.0 → 1.4.1
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 +154 -55
- package/dist/cli.js.map +1 -1
- package/dist/codex/main.js +104 -59
- package/dist/codex/main.js.map +1 -1
- package/dist/hub/server.js +27 -9
- package/dist/hub/server.js.map +1 -1
- package/dist/index.js +27 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/hub/server.js
CHANGED
|
@@ -846,6 +846,11 @@ ${bodyLines.join("\n")}`;
|
|
|
846
846
|
import { spawn } from "child_process";
|
|
847
847
|
import fs2 from "fs";
|
|
848
848
|
import path3 from "path";
|
|
849
|
+
|
|
850
|
+
// src/codex/shutdown.ts
|
|
851
|
+
var SUPERVISOR_STOP_GRACE_MS = 3e4;
|
|
852
|
+
|
|
853
|
+
// src/hub/codex-supervisor.ts
|
|
849
854
|
var HEALTHY_RUN_MS = 6e4;
|
|
850
855
|
function resolveAdapterScript(baseDir) {
|
|
851
856
|
return [path3.join(baseDir, "..", "codex", "main.js"), path3.join(baseDir, "codex", "main.js")].find((p) => fs2.existsSync(p));
|
|
@@ -861,7 +866,7 @@ var CodexSupervisor = class {
|
|
|
861
866
|
this.spawnFn = opts.spawnFn ?? spawn;
|
|
862
867
|
this.minDelayMs = opts.minDelayMs ?? 2e3;
|
|
863
868
|
this.maxDelayMs = opts.maxDelayMs ?? 6e4;
|
|
864
|
-
this.stopGraceMs = opts.stopGraceMs ??
|
|
869
|
+
this.stopGraceMs = opts.stopGraceMs ?? SUPERVISOR_STOP_GRACE_MS;
|
|
865
870
|
this.env = opts.env;
|
|
866
871
|
this.delay = this.minDelayMs;
|
|
867
872
|
}
|
|
@@ -884,11 +889,22 @@ var CodexSupervisor = class {
|
|
|
884
889
|
this.timer = void 0;
|
|
885
890
|
const child = this.child;
|
|
886
891
|
this.child = void 0;
|
|
887
|
-
if (!child) return;
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
+
if (!child) return Promise.resolve();
|
|
893
|
+
return new Promise((resolve) => {
|
|
894
|
+
const done = () => {
|
|
895
|
+
clearTimeout(force);
|
|
896
|
+
child.removeListener("exit", done);
|
|
897
|
+
resolve();
|
|
898
|
+
};
|
|
899
|
+
const force = setTimeout(() => {
|
|
900
|
+
logger.warn(`Codex adapter did not exit within ${this.stopGraceMs}ms of stop; killing it`);
|
|
901
|
+
child.kill();
|
|
902
|
+
done();
|
|
903
|
+
}, this.stopGraceMs);
|
|
904
|
+
force.unref();
|
|
905
|
+
child.once("exit", done);
|
|
906
|
+
child.stdin?.end();
|
|
907
|
+
});
|
|
892
908
|
}
|
|
893
909
|
launch() {
|
|
894
910
|
const startedAt = Date.now();
|
|
@@ -1198,9 +1214,9 @@ var HubServer = class {
|
|
|
1198
1214
|
});
|
|
1199
1215
|
}
|
|
1200
1216
|
stop() {
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1217
|
+
const adapterStopped = this.codexSupervisor?.stop();
|
|
1218
|
+
this.codexSupervisor = void 0;
|
|
1219
|
+
const serverStopped = new Promise((resolve) => {
|
|
1204
1220
|
if (this.heartbeatInterval) clearInterval(this.heartbeatInterval);
|
|
1205
1221
|
if (this.telegramBot) this.telegramBot.stopPolling();
|
|
1206
1222
|
for (const ws of this.channelSockets.values()) ws.terminate();
|
|
@@ -1220,6 +1236,8 @@ var HubServer = class {
|
|
|
1220
1236
|
resolve();
|
|
1221
1237
|
}, 3e3);
|
|
1222
1238
|
});
|
|
1239
|
+
return Promise.all([serverStopped, adapterStopped]).then(() => {
|
|
1240
|
+
});
|
|
1223
1241
|
}
|
|
1224
1242
|
// --- HTTP Handler ---
|
|
1225
1243
|
handleHttp(req, res) {
|