Router: Ensure log gzipper finishes after shutdown signal

This commit is contained in:
zzz committed 2026-08-29 12:17:50 -04:00
1 parent d4db8fbb50
commit 40ad52987f
2 files changed
+11 -2

No files matched your search

@@ -118,13 +118,17 @@ class FileLogWriter extends LogWriter {
} catch (IOException ioe) {}
}
if (_manager.shouldGzip() && currentFile != null && currentFile.length() >= _manager.getMinGzipSize()) {
// we always start a non-daemon thread for this,
// because the thread we are in now is a daemon thread.
Thread gzipper = new Gzipper(currentFile);
if (threadGzipper) {
// rotate
gzipper.setPriority(Thread.MIN_PRIORITY);
gzipper.start(); // rotate
} else {
gzipper.run(); // shutdown
// shutdown
gzipper.setPriority(Thread.MAX_PRIORITY - 1);
}
gzipper.start();
}
}
@@ -1713,7 +1713,12 @@ public class Router implements RouterClock.ClockShiftListener {
changeState(State.FINAL_SHUTDOWN_3);
clearCaches();
_log.log(Log.CRIT, "Shutdown(" + exitCode + ") complete" /* , new Exception("Shutdown") */ );
boolean waitForGzip = _context.logManager().shouldGzip();
try { _context.logManager().shutdown(); } catch (Throwable t) { }
if (waitForGzip && !_killVMOnEnd) {
// ShutdownHook calls setKillVMOnEnd(false)
try { Thread.sleep(2000); } catch (InterruptedException ie) {}
}
if (ALLOW_DYNAMIC_KEYS) {
if (_context.getBooleanProperty(PROP_DYNAMIC_KEYS))
killKeys();