If CLI main thread fails, kill the JVM no matter what.

This prevents a long running CLI process (such as CloudBees OPE
proccesses) to hang forever when the main thread fails.

Whereas if the process terminates cleanly, the wrapper (such as systemd)
can take corrective actions.
This commit is contained in:
Kohsuke Kawaguchi committed 2015-04-20 20:58:48 -07:00
1 parent 6dbf13ac2e
commit 1a8a00a82c
1 file changed
+7 -1
+7 -1
View File
@@ -384,7 +384,13 @@ public class CLI {
// h.setLevel(ALL);
// l.addHandler(h);
//
System.exit(_main(_args));
try {
System.exit(_main(_args));
} catch (Throwable t) {
// if the CLI main thread die, make sure to kill the JVM.
t.printStackTrace();
System.exit(-1);
}
}
public static int _main(String[] _args) throws Exception {