@emqo/claudebridge 0.2.1 → 0.2.2
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 +26 -20
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31,30 +31,12 @@ async function main() {
|
|
|
31
31
|
console.error("[fatal] no platform enabled");
|
|
32
32
|
process.exit(1);
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
await a.start();
|
|
36
|
-
console.log(`[claudebridge] running with ${adapters.length} adapter(s)`);
|
|
37
|
-
// Hot reload config.yaml
|
|
38
|
-
let reloadTimer = null;
|
|
39
|
-
watch(_cfgPath || "config.yaml", () => {
|
|
40
|
-
if (reloadTimer)
|
|
41
|
-
clearTimeout(reloadTimer);
|
|
42
|
-
reloadTimer = setTimeout(() => {
|
|
43
|
-
try {
|
|
44
|
-
config = reloadConfig();
|
|
45
|
-
engine.reloadConfig(config);
|
|
46
|
-
console.log("[claudebridge] config reloaded");
|
|
47
|
-
}
|
|
48
|
-
catch (err) {
|
|
49
|
-
console.error("[claudebridge] config reload failed:", err);
|
|
50
|
-
}
|
|
51
|
-
}, 500); // debounce
|
|
52
|
-
});
|
|
34
|
+
// --- Register signal handlers and hot-reload BEFORE starting adapters ---
|
|
53
35
|
const shutdown = () => {
|
|
54
36
|
console.log("[claudebridge] shutting down...");
|
|
55
37
|
for (const a of adapters)
|
|
56
38
|
a.stop();
|
|
57
|
-
process.exit(0);
|
|
39
|
+
setTimeout(() => process.exit(0), 1000);
|
|
58
40
|
};
|
|
59
41
|
process.on("SIGINT", shutdown);
|
|
60
42
|
process.on("SIGTERM", shutdown);
|
|
@@ -68,6 +50,30 @@ async function main() {
|
|
|
68
50
|
console.error("[claudebridge] config reload failed:", err);
|
|
69
51
|
}
|
|
70
52
|
});
|
|
53
|
+
// Hot reload config.yaml on file change
|
|
54
|
+
let reloadTimer = null;
|
|
55
|
+
watch(_cfgPath || "config.yaml", () => {
|
|
56
|
+
if (reloadTimer)
|
|
57
|
+
clearTimeout(reloadTimer);
|
|
58
|
+
reloadTimer = setTimeout(() => {
|
|
59
|
+
try {
|
|
60
|
+
config = reloadConfig();
|
|
61
|
+
engine.reloadConfig(config);
|
|
62
|
+
console.log("[claudebridge] config reloaded");
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
console.error("[claudebridge] config reload failed:", err);
|
|
66
|
+
}
|
|
67
|
+
}, 500); // debounce
|
|
68
|
+
});
|
|
69
|
+
// --- Start adapters (fire-and-forget, they run infinite polling loops) ---
|
|
70
|
+
for (const a of adapters) {
|
|
71
|
+
a.start().catch(err => {
|
|
72
|
+
console.error("[fatal] adapter crashed:", err);
|
|
73
|
+
process.exit(1);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
console.log(`[claudebridge] running with ${adapters.length} adapter(s)`);
|
|
71
77
|
}
|
|
72
78
|
main().catch((err) => {
|
|
73
79
|
console.error("[fatal]", err);
|