mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-06-10 15:37:28 +00:00
fix: ShutdownHook 注册顺序调整,确保 Vert.x 先于 JDBCPoolInit 关闭
JVM ShutdownHook 按注册逆序执行。将 AppMain 的 hook 移到 Deploy.start() 之前注册, 使执行顺序变为:Deploy hook(关闭 Vert.x)-> AppMain hook(关闭 JDBCPoolInit/JsParserExecutor)。
This commit is contained in:
@@ -36,9 +36,8 @@ import static cn.qaiu.vx.core.util.ConfigConstant.LOCAL;
|
||||
public class AppMain {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// start
|
||||
Deploy.instance().start(args, AppMain::exec);
|
||||
// 注册补充 ShutdownHook,关闭 core 模块无法直接依赖的资源
|
||||
// 先注册 ShutdownHook(JVM 逆序执行,先注册的后执行)
|
||||
// 确保关闭顺序:Vert.x -> JDBCPoolInit -> JsParserExecutor
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
try {
|
||||
JDBCPoolInit.instance().close();
|
||||
@@ -51,6 +50,8 @@ public class AppMain {
|
||||
// ignore
|
||||
}
|
||||
}));
|
||||
// start
|
||||
Deploy.instance().start(args, AppMain::exec);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user