Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance shutdown hook logs #12336

Merged
merged 1 commit into from
May 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private void doDestroy() {

boolean hasModuleBindSpring = false;
// check if any modules are bound to Spring
for (ModuleModel module: applicationModel.getModuleModels()) {
for (ModuleModel module : applicationModel.getModuleModels()) {
if (module.isLifeCycleManagedExternally()) {
hasModuleBindSpring = true;
break;
Expand All @@ -104,14 +104,14 @@ private void doDestroy() {
To avoid shutdown conflicts between Dubbo and Spring,
wait for the modules bound to Spring to be handled by Spring until timeout.
*/
logger.info("Waiting for modules managed by Spring to be shutdown.");
logger.info("Waiting for modules(" + applicationModel.getDesc() + ") managed by Spring to be shutdown.");
while (!applicationModel.isDestroyed() && hasModuleBindSpring
&& (System.currentTimeMillis() - start) < timeout) {
try {
TimeUnit.MILLISECONDS.sleep(10);
hasModuleBindSpring = false;
if (!applicationModel.isDestroyed()) {
for (ModuleModel module: applicationModel.getModuleModels()) {
for (ModuleModel module : applicationModel.getModuleModels()) {
if (module.isLifeCycleManagedExternally()) {
hasModuleBindSpring = true;
break;
Expand All @@ -123,11 +123,15 @@ private void doDestroy() {
Thread.currentThread().interrupt();
}
}
if (!applicationModel.isDestroyed()) {
long usage = System.currentTimeMillis() - start;
logger.info("Dubbo wait for application(" + applicationModel.getDesc() + ") managed by Spring to be shutdown failed, " +
"time usage: " + usage + "ms");
}
}
}
if (!applicationModel.isDestroyed()) {
logger.info("Dubbo shuts down application " +
"after Spring fails to do in time or doesn't do it completely.");
logger.info("Dubbo shutdown hooks execute now. " + applicationModel.getDesc());
applicationModel.destroy();
}
}
Expand Down