import { loadConfig } from "./checker/config-loader"; import { ProbeStore } from "./checker/store"; import { ProbeEngine } from "./checker/engine"; import { startServer } from "./server"; import { readRuntimeConfig } from "./config"; import { registerCheckers } from "./checker/runner"; async function main() { registerCheckers(); const { configPath } = readRuntimeConfig(); const config = await loadConfig(configPath); const store = new ProbeStore(`${config.dataDir}/probe.db`); store.syncTargets(config.targets); const engine = new ProbeEngine(store, config.targets, config.maxConcurrentChecks); engine.start(); const shutdown = () => { engine.stop(); store.close(); process.exit(0); }; process.on("SIGINT", shutdown); process.on("SIGTERM", shutdown); startServer({ config: { host: config.host, port: config.port }, mode: "development", store, }); } void main().catch((error) => { console.error("启动失败:", error instanceof Error ? error.message : error); process.exit(1); });