mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
optimize: log
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ export class WebsocketServerBase {
|
||||
});
|
||||
log(`ws服务启动成功, ${host}:${port}`);
|
||||
} catch (e: any) {
|
||||
throw Error('ws服务启动失败, ' + e.toString());
|
||||
throw Error('ws服务启动失败, 请检查监听的ip和端口' + e.toString());
|
||||
}
|
||||
this.ws.on('connection', (wsClient, req) => {
|
||||
const url: string = req.url!.split('?').shift() || '/';
|
||||
|
@@ -42,9 +42,9 @@ export class NapCatOnebot11 {
|
||||
logDebug('ob11 ready');
|
||||
ob11Config.read();
|
||||
const serviceInfo = `
|
||||
HTTP服务 ${ob11Config.enableHttp ? '已启动' : '未启动'}, 端口: ${ob11Config.httpPort}
|
||||
HTTP服务 ${ob11Config.enableHttp ? '已启动' : '未启动'}, ${ob11Config.httpHost}:${ob11Config.httpPort}
|
||||
HTTP上报服务 ${ob11Config.enableHttpPost ? '已启动' : '未启动'}, 上报地址: ${ob11Config.httpPostUrls}
|
||||
WebSocket服务 ${ob11Config.enableWs ? '已启动' : '未启动'}, 端口: ${ob11Config.wsPort}
|
||||
WebSocket服务 ${ob11Config.enableWs ? '已启动' : '未启动'}, ${ob11Config.wsHost}:${ob11Config.wsPort}
|
||||
WebSocket反向服务 ${ob11Config.enableWsReverse ? '已启动' : '未启动'}, 反向地址: ${ob11Config.wsReverseUrls}
|
||||
`;
|
||||
log(serviceInfo);
|
||||
|
@@ -15,9 +15,9 @@ class OB11HTTPServer extends HttpServerBase {
|
||||
res.send(OB11Response.error(e.stack.toString(), 200));
|
||||
}
|
||||
|
||||
protected listen(port: number) {
|
||||
protected listen(port: number, host: string) {
|
||||
if (ob11Config.enableHttp) {
|
||||
super.listen(port);
|
||||
super.listen(port, host);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user