mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-06-11 16:07:27 +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 class AppMain {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// start
|
// 先注册 ShutdownHook(JVM 逆序执行,先注册的后执行)
|
||||||
Deploy.instance().start(args, AppMain::exec);
|
// 确保关闭顺序:Vert.x -> JDBCPoolInit -> JsParserExecutor
|
||||||
// 注册补充 ShutdownHook,关闭 core 模块无法直接依赖的资源
|
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
JDBCPoolInit.instance().close();
|
JDBCPoolInit.instance().close();
|
||||||
@@ -51,6 +50,8 @@ public class AppMain {
|
|||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
// start
|
||||||
|
Deploy.instance().start(args, AppMain::exec);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user