claude-task-worker 0.12.0 → 0.13.0
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 +45 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -193,6 +193,7 @@ __export(dispatcher_exports, {
|
|
|
193
193
|
POLL_INTERVAL_MS: () => POLL_INTERVAL_MS,
|
|
194
194
|
SHUTDOWN_RETRY_TIMEOUT_MS: () => SHUTDOWN_RETRY_TIMEOUT_MS,
|
|
195
195
|
SHUTDOWN_TIMEOUT_MS: () => SHUTDOWN_TIMEOUT_MS,
|
|
196
|
+
createDispatcherShutdownHandler: () => createDispatcherShutdownHandler,
|
|
196
197
|
formatUptime: () => formatUptime,
|
|
197
198
|
monitorSessions: () => monitorSessions,
|
|
198
199
|
pollOnce: () => pollOnce,
|
|
@@ -338,11 +339,9 @@ function monitorSessions(sessions, herdr, options) {
|
|
|
338
339
|
}
|
|
339
340
|
});
|
|
340
341
|
}, pollIntervalMs);
|
|
341
|
-
pollInterval.unref();
|
|
342
342
|
const renderInterval2 = setInterval(() => {
|
|
343
343
|
renderSessionTable(sessions);
|
|
344
344
|
}, renderIntervalMs);
|
|
345
|
-
renderInterval2.unref();
|
|
346
345
|
return {
|
|
347
346
|
stop: finish,
|
|
348
347
|
done
|
|
@@ -436,6 +435,33 @@ async function shutdownDispatcher(sessions, monitorHandle, options) {
|
|
|
436
435
|
shutdownPromise = void 0;
|
|
437
436
|
}
|
|
438
437
|
}
|
|
438
|
+
function createDispatcherShutdownHandler(shutdown2) {
|
|
439
|
+
let shuttingDown2 = false;
|
|
440
|
+
let forceKilling = false;
|
|
441
|
+
const handle = async () => {
|
|
442
|
+
if (shuttingDown2) {
|
|
443
|
+
if (forceKilling) return;
|
|
444
|
+
forceKilling = true;
|
|
445
|
+
console.log("\n[dispatcher] Force killing sessions immediately...");
|
|
446
|
+
try {
|
|
447
|
+
await shutdown2({ forceKill: true });
|
|
448
|
+
} catch (error) {
|
|
449
|
+
console.error(`[dispatcher] force-kill shutdown failed: ${error}`);
|
|
450
|
+
process.exit(1);
|
|
451
|
+
}
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
shuttingDown2 = true;
|
|
455
|
+
console.log("\n[dispatcher] Stopping sessions. Waiting for them to finish... (Press Ctrl-C again to force kill)");
|
|
456
|
+
try {
|
|
457
|
+
await shutdown2();
|
|
458
|
+
} catch (error) {
|
|
459
|
+
console.error(`[dispatcher] shutdown failed: ${error}`);
|
|
460
|
+
process.exit(1);
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
return { handle, isShuttingDown: () => shuttingDown2 };
|
|
464
|
+
}
|
|
439
465
|
var getDisplayWidth2, truncateToWidth2, padToWidth2, POLL_INTERVAL_MS, SHUTDOWN_TIMEOUT_MS, SHUTDOWN_RETRY_TIMEOUT_MS, shutdownPromise;
|
|
440
466
|
var init_dispatcher = __esm({
|
|
441
467
|
async "src/dispatcher.ts"() {
|
|
@@ -2572,20 +2598,28 @@ if (hasProjectFilter()) {
|
|
|
2572
2598
|
(async () => {
|
|
2573
2599
|
let sessions = /* @__PURE__ */ new Map();
|
|
2574
2600
|
let monitorHandle;
|
|
2575
|
-
const handleShutdown = async () => {
|
|
2576
|
-
const { shutdownDispatcher: shutdownDispatcher2 } = await init_dispatcher().then(() => dispatcher_exports);
|
|
2577
|
-
await shutdownDispatcher2(sessions, monitorHandle);
|
|
2578
|
-
};
|
|
2579
|
-
process.on("SIGTERM", handleShutdown);
|
|
2580
|
-
process.on("SIGINT", handleShutdown);
|
|
2581
2601
|
const herdr = await Promise.resolve().then(() => (init_herdr(), herdr_exports));
|
|
2602
|
+
const dispatcher = await init_dispatcher().then(() => dispatcher_exports);
|
|
2603
|
+
const shutdownController = dispatcher.createDispatcherShutdownHandler(
|
|
2604
|
+
(options) => dispatcher.shutdownDispatcher(sessions, monitorHandle, options)
|
|
2605
|
+
);
|
|
2606
|
+
process.on("SIGTERM", shutdownController.handle);
|
|
2607
|
+
process.on("SIGINT", shutdownController.handle);
|
|
2582
2608
|
try {
|
|
2583
2609
|
const config = loadProjectsConfig();
|
|
2584
2610
|
const projects = resolveTargetProjects(parseProjectFilters(), config);
|
|
2585
2611
|
const forwardedCommand = buildForwardedCommand(process.argv.slice(2));
|
|
2586
|
-
|
|
2587
|
-
sessions
|
|
2588
|
-
|
|
2612
|
+
sessions = await dispatcher.runDispatcher(projects, forwardedCommand);
|
|
2613
|
+
if (sessions.size === 0) {
|
|
2614
|
+
console.log("[dispatcher] no sessions were dispatched, exiting");
|
|
2615
|
+
process.exit(0);
|
|
2616
|
+
}
|
|
2617
|
+
monitorHandle = dispatcher.monitorSessions(sessions, herdr);
|
|
2618
|
+
await monitorHandle.done;
|
|
2619
|
+
if (!shutdownController.isShuttingDown()) {
|
|
2620
|
+
console.log("[dispatcher] all sessions finished, exiting");
|
|
2621
|
+
process.exit(0);
|
|
2622
|
+
}
|
|
2589
2623
|
} catch (err) {
|
|
2590
2624
|
if (err instanceof ProjectsConfigError || err instanceof herdr.HerdrUnavailableError) {
|
|
2591
2625
|
console.error(`[dispatcher] ${err.message}`);
|