forked from I2P_Developers/i2p.i2p
Console: Register all webapps with port mapper (ticket #1749)
This commit is contained in:
@ -541,7 +541,7 @@ public class PluginStarter implements Runnable {
|
|||||||
Iterator <String> wars = pluginWars.get(appName).iterator();
|
Iterator <String> wars = pluginWars.get(appName).iterator();
|
||||||
while (wars.hasNext()) {
|
while (wars.hasNext()) {
|
||||||
String warName = wars.next();
|
String warName = wars.next();
|
||||||
WebAppStarter.stopWebApp(warName);
|
WebAppStarter.stopWebApp(ctx, warName);
|
||||||
}
|
}
|
||||||
pluginWars.get(appName).clear();
|
pluginWars.get(appName).clear();
|
||||||
}
|
}
|
||||||
|
@ -1115,7 +1115,7 @@ public class RouterConsoleRunner implements RouterApp {
|
|||||||
continue;
|
continue;
|
||||||
if (WebAppStarter.isWebAppRunning(app)) {
|
if (WebAppStarter.isWebAppRunning(app)) {
|
||||||
try {
|
try {
|
||||||
WebAppStarter.stopWebApp(app);
|
WebAppStarter.stopWebApp(_context, app);
|
||||||
} catch (Throwable t) { t.printStackTrace(); }
|
} catch (Throwable t) { t.printStackTrace(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
|
|
||||||
import net.i2p.router.RouterContext;
|
import net.i2p.router.RouterContext;
|
||||||
import net.i2p.util.FileUtil;
|
import net.i2p.util.FileUtil;
|
||||||
|
import net.i2p.util.PortMapper;
|
||||||
import net.i2p.util.SecureDirectory;
|
import net.i2p.util.SecureDirectory;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.Handler;
|
import org.eclipse.jetty.server.Handler;
|
||||||
@ -50,6 +51,7 @@ public class WebAppStarter {
|
|||||||
/**
|
/**
|
||||||
* Adds and starts.
|
* Adds and starts.
|
||||||
* Prior to 0.9.28, was not guaranteed to throw on failure.
|
* Prior to 0.9.28, was not guaranteed to throw on failure.
|
||||||
|
* Not for routerconsole.war, it's started in RouterConsoleRunner.
|
||||||
*
|
*
|
||||||
* @throws Exception just about anything, caller would be wise to catch Throwable
|
* @throws Exception just about anything, caller would be wise to catch Throwable
|
||||||
* @since public since 0.9.33, was package private
|
* @since public since 0.9.33, was package private
|
||||||
@ -64,6 +66,10 @@ public class WebAppStarter {
|
|||||||
// and the caller will know it failed
|
// and the caller will know it failed
|
||||||
wac.setThrowUnavailableOnStartupException(true);
|
wac.setThrowUnavailableOnStartupException(true);
|
||||||
wac.start();
|
wac.start();
|
||||||
|
// Doesn't have to be right, just for presence indication
|
||||||
|
int port = ctx.portMapper().getPort(PortMapper.SVC_CONSOLE, PortMapper.DEFAULT_CONSOLE_PORT);
|
||||||
|
String host = ctx.portMapper().getActualHost(PortMapper.SVC_CONSOLE, "127.0.0.1");
|
||||||
|
ctx.portMapper().register(appName, host, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,7 +83,7 @@ public class WebAppStarter {
|
|||||||
// Jetty will happily load one context on top of another without stopping
|
// Jetty will happily load one context on top of another without stopping
|
||||||
// the first one, so we remove any previous one here
|
// the first one, so we remove any previous one here
|
||||||
try {
|
try {
|
||||||
stopWebApp(appName);
|
stopWebApp(ctx, appName);
|
||||||
} catch (Throwable t) {}
|
} catch (Throwable t) {}
|
||||||
|
|
||||||
// To avoid ZipErrors from JarURLConnetion caching,
|
// To avoid ZipErrors from JarURLConnetion caching,
|
||||||
@ -141,10 +147,11 @@ public class WebAppStarter {
|
|||||||
* Throws just about anything, caller would be wise to catch Throwable
|
* Throws just about anything, caller would be wise to catch Throwable
|
||||||
* @since public since 0.9.33, was package private
|
* @since public since 0.9.33, was package private
|
||||||
*/
|
*/
|
||||||
public static void stopWebApp(String appName) {
|
public static void stopWebApp(RouterContext ctx, String appName) {
|
||||||
ContextHandler wac = getWebApp(appName);
|
ContextHandler wac = getWebApp(appName);
|
||||||
if (wac == null)
|
if (wac == null)
|
||||||
return;
|
return;
|
||||||
|
ctx.portMapper().unregister(appName);
|
||||||
try {
|
try {
|
||||||
// not graceful is default in Jetty 6?
|
// not graceful is default in Jetty 6?
|
||||||
wac.stop();
|
wac.stop();
|
||||||
|
@ -185,7 +185,7 @@ public class ConfigClientsHandler extends FormHandler {
|
|||||||
_log.error("Error stopping plugin " + app, e);
|
_log.error("Error stopping plugin " + app, e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
WebAppStarter.stopWebApp(app);
|
WebAppStarter.stopWebApp(_context, app);
|
||||||
addFormNotice(_t("Stopped webapp {0}", app));
|
addFormNotice(_t("Stopped webapp {0}", app));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,36 @@ public class PortMapper {
|
|||||||
public static final String SVC_HTTP_I2PCONTROL = "http_i2pcontrol";
|
public static final String SVC_HTTP_I2PCONTROL = "http_i2pcontrol";
|
||||||
/** @since 0.9.34 */
|
/** @since 0.9.34 */
|
||||||
public static final String SVC_HTTPS_I2PCONTROL = "https_i2pcontrol";
|
public static final String SVC_HTTPS_I2PCONTROL = "https_i2pcontrol";
|
||||||
|
/**
|
||||||
|
* To indicate presence, alternative to WebAppStarter.isWebappRunning().
|
||||||
|
* For actual base URL, use getConsoleURL()
|
||||||
|
* @since 0.9.34
|
||||||
|
*/
|
||||||
|
public static final String SVC_I2PSNARK = "i2psnark";
|
||||||
|
/**
|
||||||
|
* To indicate presence, alternative to WebAppStarter.isWebappRunning().
|
||||||
|
* For actual base URL, use getConsoleURL()
|
||||||
|
* @since 0.9.34
|
||||||
|
*/
|
||||||
|
public static final String SVC_I2PTUNNEL = "i2ptunnel";
|
||||||
|
/**
|
||||||
|
* To indicate presence, alternative to WebAppStarter.isWebappRunning().
|
||||||
|
* For actual base URL, use getConsoleURL()
|
||||||
|
* @since 0.9.34
|
||||||
|
*/
|
||||||
|
public static final String SVC_IMAGEGEN = "imagegen";
|
||||||
|
/**
|
||||||
|
* To indicate presence, alternative to WebAppStarter.isWebappRunning().
|
||||||
|
* For actual base URL, use getConsoleURL()
|
||||||
|
* @since 0.9.34
|
||||||
|
*/
|
||||||
|
public static final String SVC_SUSIDNS = "susidns";
|
||||||
|
/**
|
||||||
|
* To indicate presence, alternative to WebAppStarter.isWebappRunning().
|
||||||
|
* For actual base URL, use getConsoleURL()
|
||||||
|
* @since 0.9.34
|
||||||
|
*/
|
||||||
|
public static final String SVC_SUSIMAIL = "susimail";
|
||||||
|
|
||||||
/** @since 0.9.34 */
|
/** @since 0.9.34 */
|
||||||
public static final int DEFAULT_CONSOLE_PORT = 7657;
|
public static final int DEFAULT_CONSOLE_PORT = 7657;
|
||||||
|
Reference in New Issue
Block a user