forked from I2P_Developers/i2p.i2p
fix stop button; catch and log exceptions better
This commit is contained in:
@ -72,8 +72,9 @@ public class ConfigClientsHandler extends FormHandler {
|
||||
PluginStarter.stopPlugin(_context, app);
|
||||
PluginStarter.deletePlugin(_context, app);
|
||||
addFormNotice(_("Deleted plugin {0}", app));
|
||||
} catch (IOException e) {
|
||||
} catch (Throwable e) {
|
||||
addFormError(_("Error deleting plugin {0}", app) + ": " + e);
|
||||
_log.error("Error deleting plugin " + app, e);
|
||||
}
|
||||
}
|
||||
return;
|
||||
@ -84,8 +85,11 @@ public class ConfigClientsHandler extends FormHandler {
|
||||
String app = _action.substring(5);
|
||||
try {
|
||||
PluginStarter.stopPlugin(_context, app);
|
||||
} catch (IOException e) {}
|
||||
addFormNotice(_("Stopped plugin {0}", app));
|
||||
addFormNotice(_("Stopped plugin {0}", app));
|
||||
} catch (Throwable e) {
|
||||
addFormError(_("Error stopping plugin {0}", app) + ": " + e);
|
||||
_log.error("Error stopping plugin " + app, e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -247,8 +251,9 @@ public class ConfigClientsHandler extends FormHandler {
|
||||
path = new File(path, app + ".war");
|
||||
WebAppStarter.startWebApp(_context, s, app, path.getAbsolutePath());
|
||||
addFormNotice(_("WebApp") + " <a href=\"/" + app + "/\">" + _(app) + "</a> " + _("started") + '.');
|
||||
} catch (Exception ioe) {
|
||||
addFormError(_("Failed to start") + ' ' + _(app) + " " + ioe + '.');
|
||||
} catch (Throwable e) {
|
||||
addFormError(_("Failed to start") + ' ' + _(app) + " " + e + '.');
|
||||
_log.error("Failed to start webapp " + app, e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ public class ConfigClientsHelper extends HelperBase {
|
||||
if (showEditButton && (!edit) && !ro)
|
||||
buf.append("<button type=\"submit\" name=\"edit\" value=\"Edit ").append(index).append("\" >" + _("Edit") + "<span class=hide> ").append(index).append("</span></button>");
|
||||
if (showStopButton && (!edit))
|
||||
buf.append("<button type=\"submit\" name=\"edit\" value=\"Stop ").append(index).append("\" >" + _("Stop") + "<span class=hide> ").append(index).append("</span></button>");
|
||||
buf.append("<button type=\"submit\" name=\"action\" value=\"Stop ").append(index).append("\" >" + _("Stop") + "<span class=hide> ").append(index).append("</span></button>");
|
||||
if (showUpdateButton && (!edit) && !ro) {
|
||||
buf.append("<button type=\"submit\" name=\"action\" value=\"Check ").append(index).append("\" >" + _("Check for updates") + "<span class=hide> ").append(index).append("</span></button>");
|
||||
buf.append("<button type=\"submit\" name=\"action\" value=\"Update ").append(index).append("\" >" + _("Update") + "<span class=hide> ").append(index).append("</span></button>");
|
||||
|
@ -50,6 +50,7 @@ public class PluginStarter implements Runnable {
|
||||
startPlugins(_context);
|
||||
}
|
||||
|
||||
/** this shouldn't throw anything */
|
||||
static void startPlugins(RouterContext ctx) {
|
||||
Log log = ctx.logManager().getLog(PluginStarter.class);
|
||||
Properties props = pluginProperties();
|
||||
@ -61,7 +62,7 @@ public class PluginStarter implements Runnable {
|
||||
try {
|
||||
if (!startPlugin(ctx, app))
|
||||
log.error("Failed to start plugin: " + app);
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
log.error("Failed to start plugin: " + app, e);
|
||||
}
|
||||
}
|
||||
@ -69,7 +70,10 @@ public class PluginStarter implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
/** @return true on success */
|
||||
/**
|
||||
* @return true on success
|
||||
* @throws just about anything, caller would be wise to catch Throwable
|
||||
*/
|
||||
static boolean startPlugin(RouterContext ctx, String appName) throws Exception {
|
||||
Log log = ctx.logManager().getLog(PluginStarter.class);
|
||||
File pluginDir = new File(ctx.getAppDir(), PluginUpdateHandler.PLUGIN_DIR + '/' + appName);
|
||||
@ -159,7 +163,10 @@ public class PluginStarter implements Runnable {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** @return true on success */
|
||||
/**
|
||||
* @return true on success
|
||||
* @throws just about anything, caller would be wise to catch Throwable
|
||||
*/
|
||||
static boolean stopPlugin(RouterContext ctx, String appName) throws IOException {
|
||||
Log log = ctx.logManager().getLog(PluginStarter.class);
|
||||
File pluginDir = new File(ctx.getAppDir(), PluginUpdateHandler.PLUGIN_DIR + '/' + appName);
|
||||
|
@ -308,7 +308,10 @@ public class PluginUpdateHandler extends UpdateHandler {
|
||||
if (!PluginStarter.stopPlugin(_context, appName)) {
|
||||
// failed, ignore
|
||||
}
|
||||
} catch (IOException e) {} // ignore
|
||||
} catch (Throwable e) {
|
||||
// no updateStatus() for this one
|
||||
_log.error("Error stopping plugin " + appName, e);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (Boolean.valueOf(props.getProperty("update-only")).booleanValue()) {
|
||||
@ -347,8 +350,9 @@ public class PluginUpdateHandler extends UpdateHandler {
|
||||
updateStatus("<b>" + _("Plugin {0} installed and started", appName) + "</b>");
|
||||
else
|
||||
updateStatus("<b>" + _("Plugin {0} installed but failed to start, check logs", appName) + "</b>");
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
updateStatus("<b>" + _("Plugin {0} installed but failed to start", appName) + ": " + e + "</b>");
|
||||
_log.error("Error starting plugin " + appName, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ public class WebAppStarter {
|
||||
|
||||
/**
|
||||
* adds and starts
|
||||
* @throws just about anything, caller would be wise to catch Throwable
|
||||
*/
|
||||
static void startWebApp(I2PAppContext ctx, Server server, String appName, String warPath) throws Exception {
|
||||
File tmpdir = new File(ctx.getTempDir(), "jetty-work-" + appName + ctx.random().nextInt());
|
||||
@ -61,6 +62,7 @@ public class WebAppStarter {
|
||||
|
||||
/**
|
||||
* stop it
|
||||
* @throws just about anything, caller would be wise to catch Throwable
|
||||
*/
|
||||
static void stopWebApp(Server server, String appName) {
|
||||
// this will return a new context if one does not exist
|
||||
|
Reference in New Issue
Block a user