mirror of
https://gitee.com/actframework/actframework.git
synced 2024-11-29 18:37:37 +08:00
Shutdown app gracefully in Runtime shutdown hook
This commit is contained in:
parent
d1dbbcfd98
commit
6e453f6169
@ -1,6 +1,7 @@
|
||||
# ActFramework Change Log
|
||||
|
||||
**1.9.1**
|
||||
* Shutdown app gracefully in Runtime shutdown hook
|
||||
* Act-Test - support sending request with file array #1375
|
||||
* It reports `UNKNOWN` for OS when running act on macOS #1373
|
||||
* Hot reload not working for Bundle Resource properties #1372
|
||||
|
@ -1,26 +1,26 @@
|
||||
# Version Matrix
|
||||
|
||||
| act | 1.8.26 | 1.8.27 | 1.8.28 | 1.8.29 | 1.8.30a | 1.8.31 | 1.8.32 | 1.9.0a |
|
||||
| --- | ----: | ----: | ----: | ----: | -----: | -----: | -----: | -----: |
|
||||
| aaa | 1.6.0 | 1.6.1 | 1.6.1 | 1.7.0 | 1.7.0 | 1.7.3 | 1.8.0 | 1.10.0 |
|
||||
| beetl | 1.6.0 | 1.6.1 | 1.6.1 | 1.7.0 | 1.7.0 | 1.7.1 | 1.7.2 | 1.8.0 |
|
||||
| beetlsql | 1.7.0 | 1.7.1 | 1.7.1 | 1.8.0 | 1.8.0 | 1.8.1 | 1.8.2 | 1.8.2 |
|
||||
| ebean-java7 | 1.7.8 | 1.7.8 | 1.7.9 | 1.8.0 | 1.8.0 | 1.8.0 | 1.8.0 | 1.8.0 |
|
||||
| ebean(java8) | 1.7.9 | 1.7.9 | 1.7.10 | 1.8.0 | 1.8.0 | 1.8.0 | 1.8.0 | 1.8.0 |
|
||||
| eclipselink(java8) | 1.6.0 | 1.6.0 | 1.6.1 | 1.7.0 | 1.7.0 | 1.7.0 | 1.7.0 | 1.7.0 |
|
||||
| excel-java7 | | | | 1.8.0 | 1.8.0 | 1.8.1 | 1.9.1 | end |
|
||||
| excel | 1.7.0 | 1.7.1 | 1.7.2 | 1.8.0 | 1.8.0 | 1.8.1 | 1.9.1 | 1.9.2 |
|
||||
| freemarker | 1.3.6 | 1.3.7 | 1.3.7 | 1.4.0 | 1.4.0 | 1.4.0 | 1.4.0 | 1.4.1 |
|
||||
| hibernate | 1.6.0 | 1.6.0 | 1.6.1 | 1.7.0 | 1.7.0 | 1.7.0 | 1.7.0 | 1.7.0 |
|
||||
| jax-rs(java8) | 1.0.5 | 1.0.5 | 1.0.5 | 1.1.0 | 1.1.0 | 1.1.0 | 1.1.0 | 1.1.0 |
|
||||
| jpa-common | 1.6.0 | 1.6.0 | 1.6.1 | 1.7.0 | 1.7.0 | 1.7.0 | 1.7.0 | 1.7.0 |
|
||||
| morphia | 1.7.2 | 1.7.2 | 1.7.3 | 1.8.0 | 1.8.1 | 1.8.2 | 1.9.0 | 1.10.0 |
|
||||
| mustache(java8) | 1.4.6 | 1.4.6 | 1.4.6 | 1.5.0 | 1.5.0 | 1.5.0 | 1.5.0 | 1.5.0 |
|
||||
| social | 0.12.6 | 0.12.6 | 0.12.6 | 0.13.0 | 0.13.0 | 0.13.0 | 0.13.0 | 0.14.0 |
|
||||
| sql-common | 1.5.0 | 1.5.0 | 1.5.1 | 1.6.0 | 1.6.0 | 1.6.0 | 1.6.0 | 1.6.0 |
|
||||
| storage(java8) | 0.14.0 | 0.14.0 | 0.14.0 | 0.15.0 | 0.15.0 | 0.15.0 | 0.16.0 | 0.16.0 |
|
||||
| thymeleaf | 1.3.6 | 1.3.6 | 1.3.6 | 1.4.0 | 1.4.0 | 1.4.0 | 1.4.0 | 1.4.0 |
|
||||
| velocity | 1.3.6 | 1.3.7 | 1.3.7 | 1.4.0 | 1.4.0 | 1.4.0 | 1.4.1 | 1.4.1 |
|
||||
| act 1.8.28 | 1.8.29 | 1.8.30a | 1.8.31 | 1.8.32 | 1.9.0a | 1.9.1b |
|
||||
| --- ----: | ----: | -----: | -----: | -----: | -----: | -----: |
|
||||
| aaa 1.6.1 | 1.7.0 | 1.7.0 | 1.7.3 | 1.8.0 | 1.10.0 | 1.10.0 |
|
||||
| beetl 1.6.1 | 1.7.0 | 1.7.0 | 1.7.1 | 1.7.2 | 1.8.0 | 1.8.0 |
|
||||
| beetlsql 1.7.1 | 1.8.0 | 1.8.0 | 1.8.1 | 1.8.2 | 1.8.2 | 1.8.2 |
|
||||
| ebean-java7 1.7.9 | 1.8.0 | 1.8.0 | 1.8.0 | 1.8.0 | 1.8.0 | 1.8.0 |
|
||||
| ebean(java8) 1.7.10 | 1.8.0 | 1.8.0 | 1.8.0 | 1.8.0 | 1.8.0 | 1.8.0 |
|
||||
| eclipselink(java8) 1.6.1 | 1.7.0 | 1.7.0 | 1.7.0 | 1.7.0 | 1.7.0 | 1.7.0 |
|
||||
| excel-java7 | 1.8.0 | 1.8.0 | 1.8.1 | 1.9.1 | end | end |
|
||||
| excel 1.7.2 | 1.8.0 | 1.8.0 | 1.8.1 | 1.9.1 | 1.9.2 | 1.9.2 |
|
||||
| freemarker 1.3.7 | 1.4.0 | 1.4.0 | 1.4.0 | 1.4.0 | 1.4.1 | 1.4.1 |
|
||||
| hibernate 1.6.1 | 1.7.0 | 1.7.0 | 1.7.0 | 1.7.0 | 1.7.0 | 1.7.0 |
|
||||
| jax-rs(java8) 1.0.5 | 1.1.0 | 1.1.0 | 1.1.0 | 1.1.0 | 1.1.0 | 1.1.0 |
|
||||
| jpa-common 1.6.1 | 1.7.0 | 1.7.0 | 1.7.0 | 1.7.0 | 1.7.0 | 1.7.0 |
|
||||
| morphia 1.7.3 | 1.8.0 | 1.8.1 | 1.8.2 | 1.9.0 | 1.10.0 | 1.10.0 |
|
||||
| mustache(java8) 1.4.6 | 1.5.0 | 1.5.0 | 1.5.0 | 1.5.0 | 1.5.0 | 1.5.0 |
|
||||
| social 0.12.6 | 0.13.0 | 0.13.0 | 0.13.0 | 0.13.0 | 0.14.0 | 0.14.0 |
|
||||
| sql-common 1.5.1 | 1.6.0 | 1.6.0 | 1.6.0 | 1.6.0 | 1.6.0 | 1.6.0 |
|
||||
| storage(java8) 0.14.0 | 0.15.0 | 0.15.0 | 0.15.0 | 0.16.0 | 0.16.0 | 0.16.0 |
|
||||
| thymeleaf 1.3.6 | 1.4.0 | 1.4.0 | 1.4.0 | 1.4.0 | 1.4.0 | 1.4.0 |
|
||||
| velocity 1.3.7 | 1.4.0 | 1.4.0 | 1.4.0 | 1.4.1 | 1.4.1 | 1.4.1 |
|
||||
|
||||
## Note
|
||||
|
||||
|
2
pom.xml
2
pom.xml
@ -21,7 +21,7 @@
|
||||
<groupId>org.actframework</groupId>
|
||||
<artifactId>act</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.9.2-SNAPSHOT</version>
|
||||
<version>1.9.1b-SNAPSHOT</version>
|
||||
|
||||
<name>ACT Framework</name>
|
||||
<description>The ACT full stack MVC framework</description>
|
||||
|
@ -370,23 +370,44 @@ public final class Act {
|
||||
shutdown(app(), 0);
|
||||
}
|
||||
|
||||
public static void shutdownNow() {
|
||||
shutdown(app(), 0, false);
|
||||
}
|
||||
|
||||
public static void shutdown(final App app) {
|
||||
shutdown(app, 0);
|
||||
}
|
||||
|
||||
public static void shutdown(final App app, final int exitCode) {
|
||||
shutdown(app, exitCode, true);
|
||||
}
|
||||
|
||||
private static void shutdown(final App app, final int exitCode, boolean async) {
|
||||
if (null == appManager) {
|
||||
return;
|
||||
}
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (async) {
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (!appManager.unload(app)) {
|
||||
app.destroy();
|
||||
}
|
||||
} finally {
|
||||
shutdownAct(exitCode);
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
} else {
|
||||
try {
|
||||
if (!appManager.unload(app)) {
|
||||
app.destroy();
|
||||
}
|
||||
} finally {
|
||||
shutdownAct(exitCode);
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
}
|
||||
|
||||
public static RequestServerRestart requestRestart() {
|
||||
@ -1205,7 +1226,12 @@ public final class Act {
|
||||
return app().config().httpPort();
|
||||
}
|
||||
|
||||
private static boolean shutdownStarted = false;
|
||||
private static void shutdownAct(int exitCode) {
|
||||
if (shutdownStarted) {
|
||||
return;
|
||||
}
|
||||
shutdownStarted = true;
|
||||
clearPidFile();
|
||||
shutdownNetworkLayer();
|
||||
destroyApplicationManager();
|
||||
@ -1219,6 +1245,7 @@ public final class Act {
|
||||
destroyMetricPlugin();
|
||||
unloadConfig();
|
||||
destroyNetworkLayer();
|
||||
LOGGER.info("All components shutdown, bye!");
|
||||
if (0 != exitCode) {
|
||||
System.exit(exitCode);
|
||||
}
|
||||
@ -1260,6 +1287,7 @@ public final class Act {
|
||||
@Override
|
||||
public void run() {
|
||||
clearPidFile();
|
||||
Act.shutdownNow();
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
@ -1271,7 +1299,7 @@ public final class Act {
|
||||
String pidFile = pidFile();
|
||||
try {
|
||||
File file = new File(pidFile);
|
||||
if (!file.delete()) {
|
||||
if (null != file && file.canRead() && !file.delete()) {
|
||||
file.deleteOnExit();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -661,7 +661,7 @@ public class App extends LogSupportedDestroyableBase {
|
||||
if (null == daemonRegistry) {
|
||||
return;
|
||||
}
|
||||
info("App shutting down ....");
|
||||
info("Shutting down app [%s]....", name());
|
||||
if (Act.isDev()) {
|
||||
for (HotReloadListener listener : hotReloadListeners) {
|
||||
listener.preHotReload();
|
||||
|
Loading…
Reference in New Issue
Block a user