Console: Fix stopping of webapps when console stops (ticket #1893)

i2psnark: Only rewrite torrent config file if changed (ticket #1893)
Util: Don't sync config writes on Android/ARM (ticket #1893)
This commit is contained in:
zzz
2017-04-01 14:15:06 +00:00
parent 5eefb8b222
commit f390831835
6 changed files with 68 additions and 10 deletions

View File

@ -17,6 +17,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.SortedSet;
import java.util.StringTokenizer;
import java.util.concurrent.LinkedBlockingQueue;
@ -233,6 +234,7 @@ public class RouterConsoleRunner implements RouterApp {
changeState(STOPPING);
if (PluginStarter.pluginsEnabled(_context))
(new I2PAppThread(new PluginStopper(_context), "PluginStopper")).start();
stopAllWebApps();
try {
_server.stop();
} catch (Exception ie) {}
@ -1040,6 +1042,32 @@ public class RouterConsoleRunner implements RouterApp {
}
}
/**
* Stops all but the root webapp (routerconsole.war)
* In Jetty 9, stopping the server doesn't stop the non-root webapps,
* so we must do it here.
* There should be a better way to do this, possibly by
* making the webapps "managed".
* @since 0.9.30
*/
private void stopAllWebApps() {
Properties props = webAppProperties(_context);
Set<String> keys = props.stringPropertyNames();
for (String name : keys) {
if (name.startsWith(PREFIX) && name.endsWith(ENABLED)) {
String app = name.substring(PREFIX.length(), name.lastIndexOf(ENABLED));
if (ROUTERCONSOLE.equals(app))
continue;
if (WebAppStarter.isWebAppRunning(app)) {
try {
WebAppStarter.stopWebApp(app);
} catch (Throwable t) { t.printStackTrace(); }
}
}
}
}
static class WarFilenameFilter implements FilenameFilter {
private static final WarFilenameFilter _filter = new WarFilenameFilter();
public static WarFilenameFilter instance() { return _filter; }