Skip to content

Commit

Permalink
Merge pull request #26851 from stuartwdouglas/shutdown-logging2
Browse files Browse the repository at this point in the history
Add some debug logging on shutdown
  • Loading branch information
gsmet authored Jul 21, 2022
2 parents 718854b + 0be0a09 commit 68ba576
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ public final void stop() {
* stop, that exception is propagated.
*/
public final void stop(Runnable afterStopTask) {
Logger logger = Logger.getLogger(Application.class);
logger.debugf("Stopping application");
if (logger.isTraceEnabled()) {
logger.tracef(new RuntimeException("Application Stop Stack Trace"), "Application shutting down");
}
final Lock stateLock = this.stateLock;
stateLock.lock();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public class ApplicationLifecycleManager {
private static volatile BiConsumer<Integer, Throwable> defaultExitCodeHandler = new BiConsumer<Integer, Throwable>() {
@Override
public void accept(Integer integer, Throwable cause) {
Logger logger = Logger.getLogger(Application.class);
logger.debugf("Shutting down with exit code %s", integer);
if (logger.isTraceEnabled()) {
logger.tracef(new RuntimeException("Shutdown Stack Trace"), "Shutdown triggered");
}
System.exit(integer);
}
};
Expand Down Expand Up @@ -275,6 +280,8 @@ private static void registerSignalHandlers(final BiConsumer<Integer, Throwable>
final SignalHandler exitHandler = new SignalHandler() {
@Override
public void handle(Signal signal) {
Logger applicationLogger = Logger.getLogger(Application.class);
applicationLogger.debugf("Received signed %s, shutting down", signal.getNumber());
exitCodeHandler.accept(signal.getNumber() + 0x80, null);
}
};
Expand Down

0 comments on commit 68ba576

Please sign in to comment.