Commit 6297abcc authored by 朱劲松​'s avatar 朱劲松​

平滑退出,增加处理失败时的非正常退出.

parent d2ad80a6
......@@ -23,6 +23,7 @@ public class DefaultSignalHandler implements SignalHandler {
@Override
public void handle(Signal signal) {
try {
String applicationName = context.getApplicationName();
log.info("开始执行停止{}服务", applicationName);
GracefulShutdownProperties bean = context.getBean(GracefulShutdownProperties.class);
......@@ -42,5 +43,13 @@ public class DefaultSignalHandler implements SignalHandler {
});
log.info("{} 即将执行 @PreDestroy 方法", applicationName);
System.exit(0);
} catch (Exception e) {
// 此处可能导致异常的里面包含了logback中类未能找到, 所以增加输出到控制台.
System.out.println(e.getMessage());
log.error(e.getMessage(), e);
} finally {
System.out.println("强制退出.");
System.exit(1);
}
}
}
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