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.
// 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.
if (context.isRouterContext())
if (context.isRouterContext()) {
startLogWriter();
try {
Runtime.getRuntime().addShutdownHook(new ShutdownHook());
} catch (IllegalStateException ise) {
// shutdown in progress, fsck it
} else {
// Only in App Context.
// In Router Context, the router has its own shutdown hook,
// 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 */