mirror of
https://github.com/hpd840321/starRiverProperty.git
synced 2026-06-09 08:20:31 +08:00
fix: move graceful shutdown listener to correct class location
This commit is contained in:
+14
-13
@@ -66,20 +66,7 @@ implements WebApplicationInitializer {
|
|||||||
protected HttpUriRequest createHttpUriRequest(HttpMethod httpMethod, URI uri) {
|
protected HttpUriRequest createHttpUriRequest(HttpMethod httpMethod, URI uri) {
|
||||||
if (HttpMethod.DELETE == httpMethod) {
|
if (HttpMethod.DELETE == httpMethod) {
|
||||||
return new VMSHttpEntityEnclosingRequestBase(uri);
|
return new VMSHttpEntityEnclosingRequestBase(uri);
|
||||||
@EventListener
|
|
||||||
@Order(0)
|
|
||||||
public void onShutdown(ContextClosedEvent event) {
|
|
||||||
log.info("Graceful shutdown: draining in-flight requests ({}ms)...", SHUTDOWN_DRAIN_MS);
|
|
||||||
try {
|
|
||||||
Thread.sleep(SHUTDOWN_DRAIN_MS);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
}
|
||||||
log.info("Graceful shutdown: drain complete");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final long SHUTDOWN_DRAIN_MS = 30_000L;
|
|
||||||
}
|
|
||||||
return super.createHttpUriRequest(httpMethod, uri);
|
return super.createHttpUriRequest(httpMethod, uri);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -108,5 +95,19 @@ implements WebApplicationInitializer {
|
|||||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
|
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
|
||||||
return builder.sources(new Class[]{OrganizationServer.class});
|
return builder.sources(new Class[]{OrganizationServer.class});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventListener
|
||||||
|
@Order(0)
|
||||||
|
public void onShutdown(ContextClosedEvent event) {
|
||||||
|
log.info("Graceful shutdown: draining in-flight requests ({}ms)...", SHUTDOWN_DRAIN_MS);
|
||||||
|
try {
|
||||||
|
Thread.sleep(SHUTDOWN_DRAIN_MS);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
log.info("Graceful shutdown: drain complete");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final long SHUTDOWN_DRAIN_MS = 30_000L;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user