* helper to read the last few lines of a textfile

* use that to render the last few lines of the wrapper log on /logs.jsp (for the on demand stack trace)
* thread creation / finalization logging
* support a hard restart (stop immediately and restart the JVM) - useful for rerunning clients.config (etc)
* systray when not supported
This commit is contained in:
jrandom
2004-08-24 18:02:48 +00:00
committed by zzz
parent 71577c9b0e
commit e81c1df19f
7 changed files with 92 additions and 9 deletions

View File

@ -28,15 +28,28 @@ public class ConfigServiceHandler extends FormHandler {
} else if ("Cancel graceful shutdown".equals(_action)) {
_context.router().cancelGracefulShutdown();
addFormNotice("Graceful shutdown cancelled");
} else if ("Hard restart".equals(_action)) {
_context.router().shutdown(Router.EXIT_HARD_RESTART);
addFormNotice("Hard restart requested");
} else if ("Dump threads".equals(_action)) {
WrapperManager.requestThreadDump();
addFormNotice("Threads dumped to logs/wrapper.log");
} else if ("Show systray icon".equals(_action)) {
SysTray.getInstance().show();
addFormNotice("Systray icon enabled (if possible)");
SysTray tray = SysTray.getInstance();
if (tray != null) {
tray.show();
addFormNotice("Systray enabled");
} else {
addFormNotice("Systray not supported on this platform");
}
} else if ("Hide systray icon".equals(_action)) {
SysTray.getInstance().hide();
addFormNotice("Systray icon disabled");
SysTray tray = SysTray.getInstance();
if (tray != null) {
tray.hide();
addFormNotice("Systray disabled");
} else {
addFormNotice("Systray not supported on this platform");
}
} else {
addFormNotice("Blah blah blah. whatever. I'm not going to " + _action);
}

View File

@ -4,6 +4,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;
import net.i2p.data.DataHelper;
import net.i2p.router.RouterContext;
public class LogsHelper {
@ -39,4 +40,12 @@ public class LogsHelper {
return buf.toString();
}
public String getServiceLogs() {
String str = DataHelper.readTextFile("logs/wrapper.log", 500);
if (str == null)
return "";
else
return "<pre>" + str + "</pre>";
}
}

View File

@ -31,6 +31,7 @@
<input type="submit" name="action" value="Shutdown gracefully" />
<input type="submit" name="action" value="Shutdown immediately" />
<input type="submit" name="action" value="Cancel graceful shutdown" />
<input type="submit" name="action" value="Hard restart" />
<h4>Systray integration</h4>
On the windows platform, there is a small application to sit in the system
tray, allowing you to view the router's status (later on, I2P client applications
@ -50,7 +51,8 @@
<input type="submit" name="action" value="Don't run I2P on startup" />
<h4>Debugging</h4>
At times, it may be helpful to debug I2P by getting a thread dump. To do so,
please select the following option and review the thread dumped to logs/wrapper.log.<br />
please select the following option and review the thread dumped to
<a href="logs.jsp#servicelogs">logs/wrapper.log</a>.<br />
<input type="submit" name="action" value="Dump threads" />
</form>
</div>

View File

@ -13,7 +13,11 @@
<div class="main" id="main">
<jsp:useBean class="net.i2p.router.web.LogsHelper" id="logsHelper" scope="request" />
<jsp:setProperty name="logsHelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
<h4>Router logs:</h4>
<jsp:getProperty name="logsHelper" property="logs" />
<hr />
<h4>Service logs:</h4><a name="servicelogs"> </a>
<jsp:getProperty name="logsHelper" property="serviceLogs" />
</div>
</body>