optimize: log

This commit is contained in:
linyuchen
2024-04-27 19:21:54 +08:00
parent c90ffbeb62
commit 9748d99f34
4 changed files with 13 additions and 9 deletions

View File

@@ -110,9 +110,13 @@ export abstract class HttpServerBase {
protected listen(port: number, host: string = '0.0.0.0') {
host = host || '0.0.0.0';
this.server = this.expressAPP.listen(port, host, () => {
const info = `${this.name} started ${host}:${port}`;
log(info);
});
try {
this.server = this.expressAPP.listen(port, host, () => {
const info = `${this.name} started ${host}:${port}`;
log(info);
});
}catch (e: any) {
logError('HTTP服务启动失败, 请检查监听的ip地址和端口', e.stack.toString());
}
}
}