fix: AppMain 注册 ShutdownHook 关闭 JDBCPoolInit 和 JsParserExecutor

审查发现 9c3945f 因模块依赖问题回退了 ShutdownHook 中的清理逻辑,
导致 JDBCPoolInit 连接池和 JsParserExecutor WorkerExecutor 在进程退出时
无法被显式关闭。将清理逻辑移到 web-service 模块的 AppMain(可依赖所有模块)。
This commit is contained in:
yukaidi
2026-05-29 07:22:57 +08:00
parent d6e88f0c53
commit d1569195e4

View File

@@ -38,6 +38,19 @@ public class AppMain {
public static void main(String[] args) {
// start
Deploy.instance().start(args, AppMain::exec);
// 注册补充 ShutdownHook关闭 core 模块无法直接依赖的资源
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
JDBCPoolInit.instance().close();
} catch (Exception e) {
// ignore
}
try {
cn.qaiu.parser.customjs.JsParserExecutor.shutdownExecutor();
} catch (Exception e) {
// ignore
}
}));
}
/**