fix: 审查阻断 — BOM+信号时序+unused import+exit前等待

This commit is contained in:
LukeMackin
2026-07-22 17:33:52 +08:00
parent bca14ebe7b
commit 93ca593f1b
3 changed files with 9 additions and 7 deletions

View File

@@ -7,7 +7,7 @@
* - Connectivity check before registration
*/
import { type DeviceConfig, type DeviceIdentity } from "@yuzu-gca/shared";
import { type DeviceConfig } from "@yuzu-gca/shared";
export interface ConnectionState {
status: "disconnected" | "connecting" | "connected" | "reconnecting";

View File

@@ -58,18 +58,20 @@ console.log(` Gateway: ${config.gateway.url}`);
console.log(` Tools: ${toolHandlers.size} implemented`);
console.log(` Port: ${port}`);
bootstrap(opts, port).then(() => {
bootstrap(opts, port).then(async () => {
console.log(`[Yuzu-GCA] Ready.`);
// Start Gateway connection lifecycle
const connMgr = new ConnectionManager(config, (state) => {
console.log(`[Gateway] ${state.status} (attempt ${state.reconnectAttempt})`);
});
connMgr.start();
// Graceful shutdown
process.on("SIGINT", () => { connMgr.stop(); process.exit(0); });
process.on("SIGTERM", () => { connMgr.stop(); process.exit(0); });
// Register signal handlers BEFORE connection start
const shutdown = async () => { connMgr.stop(); setTimeout(() => process.exit(0), 300); };
process.on("SIGINT", shutdown);
process.on("SIGTERM", shutdown);
await connMgr.start();
}).catch(err => {
console.error(`[Yuzu-GCA] Fatal:`, err);
process.exit(1);