mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-06-14 17:37:29 +00:00
fix: AppMain 注册 ShutdownHook 关闭 JDBCPoolInit 和 JsParserExecutor
审查发现 9c3945f 因模块依赖问题回退了 ShutdownHook 中的清理逻辑,
导致 JDBCPoolInit 连接池和 JsParserExecutor WorkerExecutor 在进程退出时
无法被显式关闭。将清理逻辑移到 web-service 模块的 AppMain(可依赖所有模块)。
This commit is contained in:
@@ -38,6 +38,19 @@ public class AppMain {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// start
|
// start
|
||||||
Deploy.instance().start(args, AppMain::exec);
|
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
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user