aps-agent/server/bin/serve.ts

19 lines
652 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 本地启动平台服务:node server/dist/bin/serve.js(或 pnpm dev:server)。
* A1.5 会把这条命令与界面、数据库串成一条一键启动。
*/
import { startServer } from '../index.js';
const port = Number.parseInt(process.env.APS_PORT ?? '5199', 10);
const host = process.env.APS_HOST ?? '127.0.0.1';
const server = await startServer({ host, port });
console.log(`平台服务已启动:${server.url}(协议 v1)`);
console.log(`健康检查:${server.url}/v1/health`);
for (const signal of ['SIGINT', 'SIGTERM'] as const) {
process.on(signal, () => {
void server.close().then(() => process.exit(0));
});
}