Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
commons
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DevOps
commons
Commits
7387ceeb
Commit
7387ceeb
authored
Oct 18, 2018
by
朱劲松
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加 signal handler 中日志输出,标记各个环节的开始与完成.
parent
cf71cf88
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
1 deletion
+9
-1
DefaultSignalHandler.java
...ava/cn/quantgroup/tech/shutdown/DefaultSignalHandler.java
+9
-1
No files found.
shutdown-spring-boot-starter/src/main/java/cn/quantgroup/tech/shutdown/DefaultSignalHandler.java
View file @
7387ceeb
...
@@ -37,8 +37,12 @@ public class DefaultSignalHandler implements SignalHandler {
...
@@ -37,8 +37,12 @@ public class DefaultSignalHandler implements SignalHandler {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
info
(
"{} shutdown 失败"
,
shutdownBeanName
);
log
.
info
(
"{} shutdown 失败"
,
shutdownBeanName
);
}
}
log
.
info
(
"{} 即将执行 @PreDestroy 方法"
,
applicationName
);
log
.
info
(
"{} 通过 System.exit(0) 触发 @PreDestroy 方法"
,
applicationName
);
System
.
exit
(
0
);
System
.
exit
(
0
);
log
.
info
(
"{} after first System.exit(0)."
,
applicationName
);
log
.
info
(
"{} 遍历并中断所有 non-daemon 线程"
,
applicationName
);
//处理无法exit(0)的动作
//处理无法exit(0)的动作
Thread
.
getAllStackTraces
().
forEach
((
thread
,
stackTraceElements
)
->
{
Thread
.
getAllStackTraces
().
forEach
((
thread
,
stackTraceElements
)
->
{
if
(!
thread
.
isDaemon
())
{
if
(!
thread
.
isDaemon
())
{
...
@@ -48,7 +52,11 @@ public class DefaultSignalHandler implements SignalHandler {
...
@@ -48,7 +52,11 @@ public class DefaultSignalHandler implements SignalHandler {
thread
.
interrupt
();
thread
.
interrupt
();
}
}
});
});
log
.
info
(
"{} 完成所有 non-daemon 线程的中断"
,
applicationName
);
log
.
info
(
"{} 再次执行 System.exit(0)."
,
applicationName
);
System
.
exit
(
0
);
System
.
exit
(
0
);
log
.
info
(
"{} finish second System.exit(0) process."
,
applicationName
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
// 此处可能导致异常的里面包含了logback中类未能找到, 所以增加输出到控制台.
// 此处可能导致异常的里面包含了logback中类未能找到, 所以增加输出到控制台.
System
.
out
.
println
(
e
.
getMessage
());
System
.
out
.
println
(
e
.
getMessage
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment