Merge pull request #1954 from olamy/bugfix/1550-inconsistencies-shutdown-jetty-runner

fix inconsistencies shutdown for JettyRunner
This commit is contained in:
Chris Walker 2017-11-09 12:44:18 -05:00 committed by GitHub
commit 440ebcb513
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 7 deletions

View File

@ -166,8 +166,8 @@ public class Runner
System.err.println(" --out file - info/warn/debug log filename (with optional 'yyyy_mm_dd' wildcard"); System.err.println(" --out file - info/warn/debug log filename (with optional 'yyyy_mm_dd' wildcard");
System.err.println(" --host name|ip - interface to listen on (default is all interfaces)"); System.err.println(" --host name|ip - interface to listen on (default is all interfaces)");
System.err.println(" --port n - port to listen on (default 8080)"); System.err.println(" --port n - port to listen on (default 8080)");
System.err.println(" --stop-port n - port to listen for stop command"); System.err.println(" --stop-port n - port to listen for stop command (or -DSTOP.PORT)");
System.err.println(" --stop-key n - security string for stop command (required if --stop-port is present)"); System.err.println(" --stop-key n - security string for stop command (required if --stop-port is present) (or -DSTOP.KEY)");
System.err.println(" [--jar file]*n - each tuple specifies an extra jar to be added to the classloader"); System.err.println(" [--jar file]*n - each tuple specifies an extra jar to be added to the classloader");
System.err.println(" [--lib dir]*n - each tuple specifies an extra directory of jars to be added to the classloader"); System.err.println(" [--lib dir]*n - each tuple specifies an extra directory of jars to be added to the classloader");
System.err.println(" [--classes dir]*n - each tuple specifies an extra directory of classes to be added to the classloader"); System.err.println(" [--classes dir]*n - each tuple specifies an extra directory of classes to be added to the classloader");
@ -239,8 +239,8 @@ public class Runner
boolean contextPathSet = false; boolean contextPathSet = false;
int port = __defaultPort; int port = __defaultPort;
String host = null; String host = null;
int stopPort = 0; int stopPort = Integer.getInteger( "STOP.PORT", 0 );
String stopKey = null; String stopKey = System.getProperty("STOP.KEY", null);
boolean runnerServerInitialized = false; boolean runnerServerInitialized = false;
@ -297,6 +297,18 @@ public class Runner
_statsPropFile = ("unsecure".equalsIgnoreCase(_statsPropFile) ? null : _statsPropFile); _statsPropFile = ("unsecure".equalsIgnoreCase(_statsPropFile) ? null : _statsPropFile);
break; break;
default: default:
// process system property type argument so users can use in second args part
if ( args[i].startsWith( "-D" ) ){
String[] sysProps = args[i].substring(2).split("=",2);
if("STOP.KEY".equals( sysProps[0] )){
stopKey = sysProps[1];
break;
} else if("STOP.PORT".equals( sysProps[0] )){
stopPort = Integer.valueOf(sysProps[1]);
break;
}
}
// process contexts // process contexts
if (!runnerServerInitialized) // log handlers not registered, server maybe not created, etc if (!runnerServerInitialized) // log handlers not registered, server maybe not created, etc

View File

@ -45,7 +45,7 @@ import org.eclipse.jetty.util.thread.ShutdownThread;
* This thread listens on the host/port specified by the STOP.HOST/STOP.PORT * This thread listens on the host/port specified by the STOP.HOST/STOP.PORT
* system parameter (defaults to 127.0.0.1/-1 for not listening) for request * system parameter (defaults to 127.0.0.1/-1 for not listening) for request
* authenticated with the key given by the STOP.KEY system parameter * authenticated with the key given by the STOP.KEY system parameter
* (defaults to "eclipse") for admin requests. * for admin requests.
* <p> * <p>
* If the stop port is set to zero, then a random port is assigned and the * If the stop port is set to zero, then a random port is assigned and the
* port number is printed to stdout. * port number is printed to stdout.
@ -97,7 +97,7 @@ public class ShutdownMonitor
* Creates a ShutdownMonitor using configuration from the System properties. * Creates a ShutdownMonitor using configuration from the System properties.
* <p> * <p>
* <code>STOP.PORT</code> = the port to listen on (empty, null, or values less than 0 disable the stop ability)<br> * <code>STOP.PORT</code> = the port to listen on (empty, null, or values less than 0 disable the stop ability)<br>
* <code>STOP.KEY</code> = the magic key/passphrase to allow the stop (defaults to "eclipse")<br> * <code>STOP.KEY</code> = the magic key/passphrase to allow the stop<br>
* <p> * <p>
* Note: server socket will only listen on localhost, and a successful stop will issue a System.exit() call. * Note: server socket will only listen on localhost, and a successful stop will issue a System.exit() call.
*/ */
@ -105,7 +105,7 @@ public class ShutdownMonitor
{ {
this.debug = System.getProperty("DEBUG") != null; this.debug = System.getProperty("DEBUG") != null;
this.host = System.getProperty("STOP.HOST", "127.0.0.1"); this.host = System.getProperty("STOP.HOST", "127.0.0.1");
this.port = Integer.parseInt(System.getProperty("STOP.PORT", "-1")); this.port = Integer.getInteger("STOP.PORT", -1);
this.key = System.getProperty("STOP.KEY", null); this.key = System.getProperty("STOP.KEY", null);
this.exitVm = true; this.exitVm = true;
} }