fix: 审查阻断 — BOM+信号时序+unused import+exit前等待
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
* - Connectivity check before registration
|
* - Connectivity check before registration
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { type DeviceConfig, type DeviceIdentity } from "@yuzu-gca/shared";
|
import { type DeviceConfig } from "@yuzu-gca/shared";
|
||||||
|
|
||||||
export interface ConnectionState {
|
export interface ConnectionState {
|
||||||
status: "disconnected" | "connecting" | "connected" | "reconnecting";
|
status: "disconnected" | "connecting" | "connected" | "reconnecting";
|
||||||
|
|||||||
@@ -58,18 +58,20 @@ console.log(` Gateway: ${config.gateway.url}`);
|
|||||||
console.log(` Tools: ${toolHandlers.size} implemented`);
|
console.log(` Tools: ${toolHandlers.size} implemented`);
|
||||||
console.log(` Port: ${port}`);
|
console.log(` Port: ${port}`);
|
||||||
|
|
||||||
bootstrap(opts, port).then(() => {
|
bootstrap(opts, port).then(async () => {
|
||||||
console.log(`[Yuzu-GCA] Ready.`);
|
console.log(`[Yuzu-GCA] Ready.`);
|
||||||
|
|
||||||
// Start Gateway connection lifecycle
|
// Start Gateway connection lifecycle
|
||||||
const connMgr = new ConnectionManager(config, (state) => {
|
const connMgr = new ConnectionManager(config, (state) => {
|
||||||
console.log(`[Gateway] ${state.status} (attempt ${state.reconnectAttempt})`);
|
console.log(`[Gateway] ${state.status} (attempt ${state.reconnectAttempt})`);
|
||||||
});
|
});
|
||||||
connMgr.start();
|
|
||||||
|
|
||||||
// Graceful shutdown
|
// Register signal handlers BEFORE connection start
|
||||||
process.on("SIGINT", () => { connMgr.stop(); process.exit(0); });
|
const shutdown = async () => { connMgr.stop(); setTimeout(() => process.exit(0), 300); };
|
||||||
process.on("SIGTERM", () => { connMgr.stop(); process.exit(0); });
|
process.on("SIGINT", shutdown);
|
||||||
|
process.on("SIGTERM", shutdown);
|
||||||
|
|
||||||
|
await connMgr.start();
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.error(`[Yuzu-GCA] Fatal:`, err);
|
console.error(`[Yuzu-GCA] Fatal:`, err);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"compilerOptions":{"target":"ES2022","module":"Node16","outDir":"dist","rootDir":"src","declaration":true,"strict":true,"esModuleInterop":true,"skipLibCheck":true},"include":["src"]}
|
{"compilerOptions":{"target":"ES2022","module":"Node16","outDir":"dist","rootDir":"src","declaration":true,"strict":true,"esModuleInterop":true,"skipLibCheck":true},"include":["src"]}
|
||||||
|
|||||||
Reference in New Issue
Block a user