forked from I2P_Developers/i2p.i2p
Router: Tweak shutdown messages
Change one from CRIT to WARN Translate one of them Attempt to translate class name in notifications
This commit is contained in:
@@ -39,6 +39,7 @@ fi
|
||||
# router/ now has its own bundle for some files
|
||||
ROUTERFILES="\
|
||||
../../../router/java/src/net/i2p/router/Blocklist.java \
|
||||
../../../router/java/src/net/i2p/router/Router.java \
|
||||
../../../router/java/src/net/i2p/router/networkdb/reseed/Reseeder.java \
|
||||
../../../router/java/src/net/i2p/router/sybil/Analysis.java \
|
||||
../../../router/java/src/net/i2p/router/tasks/CoalesceStatsEvent.java \
|
||||
|
||||
@@ -166,6 +166,7 @@ abstract class LogWriter implements Runnable {
|
||||
}
|
||||
|
||||
private static final String BUNDLE_NAME = "net.i2p.util.messages";
|
||||
private static final String ROUTER_BUNDLE_NAME = "net.i2p.router.web.messages";
|
||||
|
||||
/**
|
||||
* gettext
|
||||
@@ -222,7 +223,10 @@ abstract class LogWriter implements Runnable {
|
||||
if (name == null)
|
||||
name = "I2P";
|
||||
}
|
||||
ns.notify(name, null, priority, name, msg, null);
|
||||
// the class name usually won't be translated,
|
||||
// but it will be for "Router"
|
||||
String tname = Translate.getString(name, _manager.getContext(), ROUTER_BUNDLE_NAME);
|
||||
ns.notify(name, null, priority, tname, msg, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,6 +108,7 @@ public class Router implements RouterClock.ClockShiftListener {
|
||||
private UPnPScannerCallback _upnpScannerCallback;
|
||||
private long _downtime = -1;
|
||||
|
||||
private static final String BUNDLE_NAME = "net.i2p.router.web.messages";
|
||||
public final static String PROP_CONFIG_FILE = "router.configLocation";
|
||||
|
||||
/** let clocks be off by 1 minute */
|
||||
@@ -1443,7 +1444,10 @@ public class Router implements RouterClock.ClockShiftListener {
|
||||
// help us shut down esp. after OOM
|
||||
int priority = (exitCode == EXIT_OOM) ? Thread.MAX_PRIORITY - 1 : Thread.NORM_PRIORITY + 2;
|
||||
Thread.currentThread().setPriority(priority);
|
||||
_log.log(Log.CRIT, "Starting final shutdown(" + exitCode + ')');
|
||||
if (exitCode == EXIT_HARD_RESTART || exitCode == EXIT_GRACEFUL_RESTART)
|
||||
_log.log(Log.CRIT, _t("Restart imminent"));
|
||||
else
|
||||
_log.log(Log.CRIT, _t("Shutdown imminent"));
|
||||
// So we can get all the way to the end
|
||||
// No, you can't do Thread.currentThread.setDaemon(false)
|
||||
if (_killVMOnEnd) {
|
||||
@@ -1943,7 +1947,7 @@ public class Router implements RouterClock.ClockShiftListener {
|
||||
f.delete();
|
||||
if (lastWritten > 0)
|
||||
_eventLog.addEvent(EventLog.CRASHED,
|
||||
Translate.getString("{0} ago", DataHelper.formatDuration2(downtime), _context, "net.i2p.router.web.messages"));
|
||||
Translate.getString("{0} ago", DataHelper.formatDuration2(downtime), _context, BUNDLE_NAME));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -2137,4 +2141,12 @@ public class Router implements RouterClock.ClockShiftListener {
|
||||
recv = (int)rs.getRate(5*60*1000).getAverageValue();
|
||||
return Math.max(send, recv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate with console bundle
|
||||
* @since 0.9.53
|
||||
*/
|
||||
private final String _t(String s) {
|
||||
return Translate.getString(s, _context, BUNDLE_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,12 +26,14 @@ public class GracefulShutdown implements Runnable {
|
||||
int gracefulExitCode = _context.router().scheduledGracefulExitCode();
|
||||
if (gracefulExitCode == Router.EXIT_HARD || gracefulExitCode == Router.EXIT_HARD_RESTART ||
|
||||
_context.tunnelManager().getParticipatingCount() <= 0) {
|
||||
if (gracefulExitCode == Router.EXIT_HARD)
|
||||
log.log(Log.CRIT, "Shutting down after a brief delay");
|
||||
else if (gracefulExitCode == Router.EXIT_HARD_RESTART)
|
||||
log.log(Log.CRIT, "Restarting after a brief delay");
|
||||
else
|
||||
log.log(Log.CRIT, "Graceful shutdown progress: No more tunnels, starting final shutdown");
|
||||
if (log.shouldWarn()) {
|
||||
if (gracefulExitCode == Router.EXIT_HARD)
|
||||
log.warn("Shutting down after a brief delay");
|
||||
else if (gracefulExitCode == Router.EXIT_HARD_RESTART)
|
||||
log.warn("Restarting after a brief delay");
|
||||
else
|
||||
log.warn("Graceful shutdown progress: No more tunnels, starting final shutdown");
|
||||
}
|
||||
// Allow time for a UI reponse
|
||||
try {
|
||||
synchronized (Thread.currentThread()) {
|
||||
|
||||
Reference in New Issue
Block a user