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
77bd7035
Commit
77bd7035
authored
May 09, 2018
by
xiaoguang.xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix : 默认shutdown 第一个找到的容器
parent
70a7c44a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
8 deletions
+13
-8
pom.xml
pom.xml
+7
-5
DefaultSignalHandler.java
...ava/cn/quantgroup/tech/shutdown/DefaultSignalHandler.java
+6
-3
No files found.
pom.xml
View file @
77bd7035
...
@@ -25,11 +25,13 @@
...
@@ -25,11 +25,13 @@
<properties>
<properties>
<java.version>
1.8
</java.version>
<java.version>
1.8
</java.version>
<lombok.version>
1.16.20
</lombok.version>
<guava.version>
23.0
</guava.version>
<guava.version>
23.0
</guava.version>
<apollo.client.version>
0.10.2
</apollo.client.version>
<apollo.client.version>
0.10.2
</apollo.client.version>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<maven.test.skip>
true
</maven.test.skip>
<maven.test.skip>
true
</maven.test.skip>
<common.parent.version>
0.2.0
</common.parent.version>
</properties>
</properties>
<dependencies>
<dependencies>
...
@@ -43,7 +45,7 @@
...
@@ -43,7 +45,7 @@
<dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<artifactId>
lombok
</artifactId>
<version>
1.16.20
</version>
<version>
${lombok.version}
</version>
</dependency>
</dependency>
</dependencies>
</dependencies>
...
@@ -52,22 +54,22 @@
...
@@ -52,22 +54,22 @@
<dependency>
<dependency>
<groupId>
cn.quantgroup
</groupId>
<groupId>
cn.quantgroup
</groupId>
<artifactId>
commons-spring
</artifactId>
<artifactId>
commons-spring
</artifactId>
<version>
0.2.0
</version>
<version>
${common.parent.version}
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
cn.quantgroup
</groupId>
<groupId>
cn.quantgroup
</groupId>
<artifactId>
commons-core
</artifactId>
<artifactId>
commons-core
</artifactId>
<version>
0.2.0
</version>
<version>
${common.parent.version}
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
cn.quantgroup
</groupId>
<groupId>
cn.quantgroup
</groupId>
<artifactId>
shutdown-spring-boot-starter
</artifactId>
<artifactId>
shutdown-spring-boot-starter
</artifactId>
<version>
0.2.0
</version>
<version>
${common.parent.version}
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
cn.quantgroup
</groupId>
<groupId>
cn.quantgroup
</groupId>
<artifactId>
brave-spring-boot-starter
</artifactId>
<artifactId>
brave-spring-boot-starter
</artifactId>
<version>
0.2.0
</version>
<version>
${common.parent.version}
</version>
</dependency>
</dependency>
</dependencies>
</dependencies>
</dependencyManagement>
</dependencyManagement>
...
...
shutdown-spring-boot-starter/src/main/java/cn/quantgroup/tech/shutdown/DefaultSignalHandler.java
View file @
77bd7035
...
@@ -27,12 +27,15 @@ public class DefaultSignalHandler implements SignalHandler {
...
@@ -27,12 +27,15 @@ public class DefaultSignalHandler implements SignalHandler {
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
);
String
shutdownBeanName
=
null
;
try
{
try
{
String
[]
shutdownBeanNames
=
context
.
getBeanNamesForType
(
Shutdown
.
class
);
shutdownBeanName
=
shutdownBeanNames
[
0
];
//如果不是web应用. 这里会找不到shutdown bean
//如果不是web应用. 这里会找不到shutdown bean
context
.
getBean
(
Shutdown
.
class
).
shutdown
(
bean
.
getTimeout
());
context
.
getBean
(
shutdownBeanName
,
Shutdown
.
class
).
shutdown
(
bean
.
getTimeout
());
log
.
info
(
"
servlet container
停止接收请求"
);
log
.
info
(
"
web 容器
停止接收请求"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
info
(
"Web 容器 shutdown 失败,
可能没有 Web 容器"
);
log
.
info
(
"Web 容器 shutdown 失败,
检测到你的容器是: {}"
,
shutdownBeanName
);
}
}
log
.
info
(
"{} 即将执行 @PreDestroy 方法"
,
applicationName
);
log
.
info
(
"{} 即将执行 @PreDestroy 方法"
,
applicationName
);
System
.
exit
(
0
);
System
.
exit
(
0
);
...
...
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