Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
完善 重启输出报错&细节问题
Browse files Browse the repository at this point in the history
  • Loading branch information
YuMao233 committed Mar 16, 2022
1 parent ce254b2 commit 72fcf08
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/entity/commands/general/general _restart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default class GeneralRestartCommand extends InstanceCommand {
} catch (error) {
clearInterval(task);
instance.setLock(false);
throw error;
instance.failure(error);
}
}, 1000);
} catch (error) {
Expand Down
1 change: 1 addition & 0 deletions src/entity/instance/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ export default class Instance extends EventEmitter {
return 0;
}

// 执行预设命令动作
async execPreset(action: string, p?: any) {
if (this.presetCommandManager) {
return await this.presetCommandManager.execPreset(action, p);
Expand Down
2 changes: 1 addition & 1 deletion src/routers/stream_router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ routerApp.use(async (event, ctx, data, next) => {
if (ctx.session.stream && ctx.session.stream.check === true && ctx.session.type === "STREAM") {
return await next();
}
return protocol.error(ctx, "error", "权限不足,非法访问");
return protocol.error(ctx, "error", "[Unauthorized Access] 权限不足,非法访问");
}
return await next();
});
Expand Down
8 changes: 6 additions & 2 deletions src/service/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ export function responseError(ctx: RouterContext, err: Error | string) {
if (err) errinfo = err.toString();
else errinfo = err;
const packet = new Packet(ctx.uuid, STATUS_ERR, ctx.event, errinfo);
logger.error(`会话 ${ctx.socket.id}(${ctx.socket.handshake.address})/${ctx.event} 响应数据时异常:\n`, err);
// 忽略因为重启守护进程没有刷新网页的权限不足错误
if (err.toString().includes("[Unauthorized Access]")) return ctx.socket.emit(ctx.event, packet);
logger.warn(`会话 ${ctx.socket.id}(${ctx.socket.handshake.address})/${ctx.event} 响应数据时异常:\n`, err);
ctx.socket.emit(ctx.event, packet);
}

Expand All @@ -64,7 +66,9 @@ export function msg(ctx: RouterContext, event: string, data: any) {

export function error(ctx: RouterContext, event: string, err: any) {
const packet = new Packet(ctx.uuid, STATUS_ERR, event, err);
logger.error(`会话 ${ctx.socket.id}(${ctx.socket.handshake.address})/${event} 响应数据时异常:\n`, err);
// 忽略因为重启守护进程没有刷新网页的权限不足错误
if (err.toString().includes("[Unauthorized Access]")) return ctx.socket.emit(ctx.event, packet);
logger.warn(`会话 ${ctx.socket.id}(${ctx.socket.handshake.address})/${event} 响应数据时异常:\n`, err);
ctx.socket.emit(event, packet);
}

Expand Down

0 comments on commit 72fcf08

Please sign in to comment.