修复 koa 错误报告和计划任务加载错误

This commit is contained in:
Suwings 2022-04-09 19:47:12 +08:00
parent e4de175812
commit e2ccae3225
2 changed files with 13 additions and 1 deletions

View File

@ -60,6 +60,13 @@ const config = globalConfiguration.config;
// 初始化 HTTP 服务
const koaApp = koa.initKoa();
// 监听 Koa 错误
koaApp.on("error", (error) => {
// 屏蔽所有 Koa 框架级别事件
// 当 Koa 遭遇短连接洪水攻击时,很容易错误信息刷屏,有可能会间接影响某些应用程序运作
});
const httpServer = http.createServer(koaApp.callback());
httpServer.listen(config.port, config.ip);

View File

@ -82,7 +82,12 @@ class InstanceControlSubsystem {
// 初始化所有持久化数据并逐一装载到内存
StorageSubsystem.list("TaskConfig").forEach((uuid) => {
const config = StorageSubsystem.load("TaskConfig", TaskConfig, uuid) as TaskConfig;
this.registerScheduleJob(config, false);
try {
this.registerScheduleJob(config, false);
} catch (error) {
// 可能会遗留掉某些计划任务,但是上限不会变
// 忽略启动时的计划任务注册
}
});
}