Commit 7387ceeb authored by 朱劲松​'s avatar 朱劲松​

增加 signal handler 中日志输出,标记各个环节的开始与完成.

parent cf71cf88
......@@ -37,8 +37,12 @@ public class DefaultSignalHandler implements SignalHandler {
} catch (Exception e) {
log.info("{} shutdown 失败", shutdownBeanName);
}
log.info("{} 即将执行 @PreDestroy 方法", applicationName);
log.info("{} 通过 System.exit(0) 触发 @PreDestroy 方法", applicationName);
System.exit(0);
log.info("{} after first System.exit(0).", applicationName);
log.info("{} 遍历并中断所有 non-daemon 线程", applicationName);
//处理无法exit(0)的动作
Thread.getAllStackTraces().forEach((thread, stackTraceElements) -> {
if (!thread.isDaemon()) {
......@@ -48,7 +52,11 @@ public class DefaultSignalHandler implements SignalHandler {
thread.interrupt();
}
});
log.info("{} 完成所有 non-daemon 线程的中断", applicationName);
log.info("{} 再次执行 System.exit(0).", applicationName);
System.exit(0);
log.info("{} finish second System.exit(0) process.", applicationName);
} catch (Exception e) {
// 此处可能导致异常的里面包含了logback中类未能找到, 所以增加输出到控制台.
System.out.println(e.getMessage());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment