- Start webapps after console for faster startup

- Add delay in systray port checker to ensure console is up
- Move I2PRequestLog to net.i2p.jetty package
This commit is contained in:
zzz
2011-12-29 23:25:27 +00:00
parent 07162b56c8
commit be7623a462
4 changed files with 45 additions and 31 deletions

View File

@ -12,7 +12,7 @@
//limitations under the License. //limitations under the License.
//======================================================================== //========================================================================
package org.mortbay.http; package net.i2p.jetty;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;

View File

@ -275,7 +275,6 @@ public class RouterConsoleRunner {
if (!_webAppsDir.endsWith("/")) if (!_webAppsDir.endsWith("/"))
_webAppsDir += '/'; _webAppsDir += '/';
List<String> notStarted = new ArrayList();
WebAppContext rootWebApp = null; WebAppContext rootWebApp = null;
ServletHandler rootServletHandler = null; ServletHandler rootServletHandler = null;
try { try {
@ -369,38 +368,10 @@ public class RouterConsoleRunner {
initialize(rootWebApp); initialize(rootWebApp);
chColl.addHandler(rootWebApp); chColl.addHandler(rootWebApp);
File dir = new File(_webAppsDir);
String fileNames[] = dir.list(WarFilenameFilter.instance());
if (fileNames != null) {
for (int i = 0; i < fileNames.length; i++) {
try {
String appName = fileNames[i].substring(0, fileNames[i].lastIndexOf(".war"));
String enabled = props.getProperty(PREFIX + appName + ENABLED);
if (! "false".equals(enabled)) {
String path = new File(dir, fileNames[i]).getCanonicalPath();
tmpdir = new SecureDirectory(workDir, appName + "-" +
(_listenPort != null ? _listenPort : _sslListenPort));
WebAppStarter.addWebApp(I2PAppContext.getGlobalContext(), chColl, appName, path, tmpdir);
if (enabled == null) {
// do this so configclients.jsp knows about all apps from reading the config
props.setProperty(PREFIX + appName + ENABLED, "true");
rewrite = true;
}
} else {
notStarted.add(appName);
}
} catch (IOException ioe) {
System.err.println("Error resolving '" + fileNames[i] + "' in '" + dir);
}
}
}
} catch (Exception ioe) { } catch (Exception ioe) {
ioe.printStackTrace(); ioe.printStackTrace();
} }
if (rewrite)
storeWebAppProperties(props);
try { try {
// start does a mapContexts() // start does a mapContexts()
_server.start(); _server.start();
@ -415,6 +386,44 @@ public class RouterConsoleRunner {
me.printStackTrace(); me.printStackTrace();
} }
// Start all the other webapps after the server is up,
// so things start faster.
// Jetty 6 starts the connector before the router console is ready
// This also prevents one webapp from breaking the whole thing
List<String> notStarted = new ArrayList();
if (_server.isRunning()) {
File dir = new File(_webAppsDir);
String fileNames[] = dir.list(WarFilenameFilter.instance());
if (fileNames != null) {
for (int i = 0; i < fileNames.length; i++) {
String appName = fileNames[i].substring(0, fileNames[i].lastIndexOf(".war"));
String enabled = props.getProperty(PREFIX + appName + ENABLED);
if (! "false".equals(enabled)) {
try {
String path = new File(dir, fileNames[i]).getCanonicalPath();
WebAppStarter.startWebApp(I2PAppContext.getGlobalContext(), chColl, appName, path);
if (enabled == null) {
// do this so configclients.jsp knows about all apps from reading the config
props.setProperty(PREFIX + appName + ENABLED, "true");
rewrite = true;
}
} catch (Throwable t) {
System.err.println("ERROR: Failed to start " + appName + ' ' + t);
t.printStackTrace();
notStarted.add(appName);
}
} else {
notStarted.add(appName);
}
}
}
} else {
System.err.println("ERROR: Router console did not start, not starting webapps");
}
if (rewrite)
storeWebAppProperties(props);
if (rootServletHandler != null && notStarted.size() > 0) { if (rootServletHandler != null && notStarted.size() > 0) {
// map each not-started webapp to the error page // map each not-started webapp to the error page
ServletHolder noWebApp = rootServletHandler.getServlet("net.i2p.router.web.jsp.nowebapp_jsp"); ServletHolder noWebApp = rootServletHandler.getServlet("net.i2p.router.web.jsp.nowebapp_jsp");

View File

@ -77,6 +77,11 @@ public class UrlLauncher {
try { try {
test.close(); test.close();
} catch (IOException ioe) {} } catch (IOException ioe) {}
// Jetty 6 seems to start the Connector before the
// webapp is completely ready
try {
Thread.sleep(2*1000);
} catch (InterruptedException ie) {}
return true; return true;
} catch (Exception e) {} } catch (Exception e) {}
if (System.currentTimeMillis() > done) if (System.currentTimeMillis() > done)

View File

@ -238,7 +238,7 @@
<!-- =========================================================== --> <!-- =========================================================== -->
<Ref id="RequestLog"> <Ref id="RequestLog">
<Set name="requestLog"> <Set name="requestLog">
<New id="RequestLogImpl" class="org.mortbay.http.I2PRequestLog"> <New id="RequestLogImpl" class="net.i2p.jetty.I2PRequestLog">
<Set name="filename">./eepsite/logs/yyyy_mm_dd.request.log</Set> <Set name="filename">./eepsite/logs/yyyy_mm_dd.request.log</Set>
<Set name="filenameDateFormat">yyyy_MM_dd</Set> <Set name="filenameDateFormat">yyyy_MM_dd</Set>
<Set name="retainDays">90</Set> <Set name="retainDays">90</Set>