xindex 1.0.17 → 1.0.18
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/apps/run.mcp.ts +11 -5
- package/package.json +1 -1
package/apps/run.mcp.ts
CHANGED
|
@@ -45,16 +45,22 @@ const watch = watchDisabled ? undefined : {
|
|
|
45
45
|
watcherLock,
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
let shuttingDown = false;
|
|
49
|
+
const shutdown = async (reason: string) => {
|
|
50
|
+
if (shuttingDown) return;
|
|
51
|
+
shuttingDown = true;
|
|
52
|
+
log(`shutdown (${reason}) — stopping heartbeat...`);
|
|
50
53
|
watcherLock.stopHeartbeat();
|
|
51
54
|
log(`releasing lock...`);
|
|
52
55
|
await watcherLock.release();
|
|
53
|
-
log(`waiting 7s for another watcher to take over...`);
|
|
54
|
-
await new Promise(r => setTimeout(r, 7000));
|
|
55
56
|
log(`exiting`);
|
|
56
57
|
process.exit(0);
|
|
57
|
-
}
|
|
58
|
+
};
|
|
59
|
+
process.on("SIGINT", () => shutdown("SIGINT"));
|
|
60
|
+
process.on("SIGTERM", () => shutdown("SIGTERM"));
|
|
61
|
+
process.on("SIGHUP", () => shutdown("SIGHUP"));
|
|
62
|
+
process.stdin.on("close", () => shutdown("stdin-close"));
|
|
63
|
+
process.stdin.on("end", () => shutdown("stdin-end"));
|
|
58
64
|
|
|
59
65
|
log(`[${appId}] started`);
|
|
60
66
|
const mcpApp = McpApp({search, indexApp, getIndexStats, resetIndex, log, watch, config});
|