LogManager: Don't register runtime shutdown hook in router context.

This was causing shutdown() to be called twice, resulting
in lost log messages when stopped from i2prouter.
This commit is contained in:
zzz
2018-02-28 20:04:40 +00:00
parent 5cd1419897
commit d167b5eafb

View File

@ -150,14 +150,18 @@ public class LogManager implements Flushable {
// so it doesn't create a log directory and log files unless there is output. // so it doesn't create a log directory and log files unless there is output.
// In the router context, we have to rotate to a new log file at startup or the logs.jsp // In the router context, we have to rotate to a new log file at startup or the logs.jsp
// page will display the old log. // page will display the old log.
if (context.isRouterContext()) if (context.isRouterContext()) {
startLogWriter(); startLogWriter();
try { } else {
Runtime.getRuntime().addShutdownHook(new ShutdownHook()); // Only in App Context.
} catch (IllegalStateException ise) { // In Router Context, the router has its own shutdown hook,
// shutdown in progress, fsck it // and will call our shutdown() from Router.finalShutdown()
try {
Runtime.getRuntime().addShutdownHook(new ShutdownHook());
} catch (IllegalStateException ise) {
// shutdown in progress
}
} }
//System.out.println("Created logManager " + this + " with context: " + context);
} }
/** @since 0.8.2 */ /** @since 0.8.2 */