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
6297abcc
Commit
6297abcc
authored
Dec 14, 2017
by
朱劲松
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
平滑退出,增加处理失败时的非正常退出.
parent
d2ad80a6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
17 deletions
+26
-17
DefaultSignalHandler.java
...ava/cn/quantgroup/tech/shutdown/DefaultSignalHandler.java
+26
-17
No files found.
src/main/java/cn/quantgroup/tech/shutdown/DefaultSignalHandler.java
View file @
6297abcc
...
@@ -23,6 +23,7 @@ public class DefaultSignalHandler implements SignalHandler {
...
@@ -23,6 +23,7 @@ public class DefaultSignalHandler implements SignalHandler {
@Override
@Override
public
void
handle
(
Signal
signal
)
{
public
void
handle
(
Signal
signal
)
{
try
{
String
applicationName
=
context
.
getApplicationName
();
String
applicationName
=
context
.
getApplicationName
();
log
.
info
(
"开始执行停止{}服务"
,
applicationName
);
log
.
info
(
"开始执行停止{}服务"
,
applicationName
);
GracefulShutdownProperties
bean
=
context
.
getBean
(
GracefulShutdownProperties
.
class
);
GracefulShutdownProperties
bean
=
context
.
getBean
(
GracefulShutdownProperties
.
class
);
...
@@ -42,5 +43,13 @@ public class DefaultSignalHandler implements SignalHandler {
...
@@ -42,5 +43,13 @@ public class DefaultSignalHandler implements SignalHandler {
});
});
log
.
info
(
"{} 即将执行 @PreDestroy 方法"
,
applicationName
);
log
.
info
(
"{} 即将执行 @PreDestroy 方法"
,
applicationName
);
System
.
exit
(
0
);
System
.
exit
(
0
);
}
catch
(
Exception
e
)
{
// 此处可能导致异常的里面包含了logback中类未能找到, 所以增加输出到控制台.
System
.
out
.
println
(
e
.
getMessage
());
log
.
error
(
e
.
getMessage
(),
e
);
}
finally
{
System
.
out
.
println
(
"强制退出."
);
System
.
exit
(
1
);
}
}
}
}
}
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