Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2015-03-25 03:00:23 +0000
committerGreg Wilkins2015-03-25 03:00:23 +0000
commit1d99c0af7bf29dd1f852b13d15bd98e47118919d (patch)
treeb70d19f2d4fdca029eaf3949bc1230fec2eec7c3
parentd20c7707b7fc2e82c75732fb944f65764a0b9d1c (diff)
parent8c652fd5bd0dcc067f225bd71b079bc0260fd578 (diff)
downloadorg.eclipse.jetty.project-1d99c0af7bf29dd1f852b13d15bd98e47118919d.tar.gz
org.eclipse.jetty.project-1d99c0af7bf29dd1f852b13d15bd98e47118919d.tar.xz
org.eclipse.jetty.project-1d99c0af7bf29dd1f852b13d15bd98e47118919d.zip
Merge remote-tracking branch 'origin/jetty-9.2.x'
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/ShutdownMonitor.java12
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/Main.java27
-rw-r--r--jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt4
3 files changed, 24 insertions, 19 deletions
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ShutdownMonitor.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ShutdownMonitor.java
index d2da9a9a63..3b71a745ca 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/ShutdownMonitor.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ShutdownMonitor.java
@@ -28,10 +28,8 @@ import java.net.ServerSocket;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
-import java.util.List;
import java.util.Properties;
import java.util.Set;
-import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;
import org.eclipse.jetty.util.component.Destroyable;
@@ -41,8 +39,8 @@ import org.eclipse.jetty.util.thread.ShutdownThread;
/**
* Shutdown/Stop Monitor thread.
* <p>
- * This thread listens on the port specified by the STOP.PORT system parameter (defaults to -1 for not listening) for request authenticated with the key given
- * by the STOP.KEY system parameter (defaults to "eclipse") for admin requests.
+ * 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 authenticated with the key given by the STOP.KEY system parameter (defaults to "eclipse") for admin requests.
* <p>
* If the stop port is set to zero, then a random port is assigned and the port number is printed to stdout.
* <p>
@@ -82,7 +80,7 @@ public class ShutdownMonitor
return getInstance()._lifeCycles.contains(lifeCycle);
}
-
+ /* ------------------------------------------------------------ */
/**
* ShutdownMonitorRunnable
*
@@ -297,7 +295,7 @@ public class ShutdownMonitor
{
serverSocket = new ServerSocket();
serverSocket.setReuseAddress(true);
- serverSocket.bind(new InetSocketAddress(InetAddress.getByName("127.0.0.1"), port), 1);
+ serverSocket.bind(new InetSocketAddress(InetAddress.getByName(host), port), 1);
if (port == 0)
{
// server assigned port in use
@@ -330,6 +328,7 @@ public class ShutdownMonitor
}
private boolean DEBUG;
+ private String host;
private int port;
private String key;
private boolean exitVm;
@@ -351,6 +350,7 @@ public class ShutdownMonitor
this.DEBUG = props.containsKey("DEBUG");
// Use values passed thru via /jetty-start/
+ this.host = props.getProperty("STOP.HOST","127.0.0.1");
this.port = Integer.parseInt(props.getProperty("STOP.PORT","-1"));
this.key = props.getProperty("STOP.KEY",null);
this.exitVm = true;
diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java
index e4af9bfb56..62926ea2ec 100644
--- a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java
+++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java
@@ -450,6 +450,7 @@ public class Main
private void doStop(StartArgs args)
{
+ String stopHost = args.getProperties().getString("STOP.HOST");
int stopPort = Integer.parseInt(args.getProperties().getString("STOP.PORT"));
String stopKey = args.getProperties().getString("STOP.KEY");
@@ -457,41 +458,41 @@ public class Main
{
int stopWait = Integer.parseInt(args.getProperties().getString("STOP.WAIT"));
- stop(stopPort,stopKey,stopWait);
+ stop(stopHost,stopPort,stopKey,stopWait);
}
else
{
- stop(stopPort,stopKey);
+ stop(stopHost,stopPort,stopKey);
}
}
/**
* Stop a running jetty instance.
*/
- public void stop(int port, String key)
+ public void stop(String host, int port, String key)
{
- stop(port,key,0);
+ stop(host,port,key,0);
}
- public void stop(int port, String key, int timeout)
+ public void stop(String host, int port, String key, int timeout)
{
- int _port = port;
- String _key = key;
-
+ if (host==null || host.length()==0)
+ host="127.0.0.1";
+
try
{
- if (_port <= 0)
+ if (port <= 0)
{
System.err.println("STOP.PORT system property must be specified");
}
- if (_key == null)
+ if (key == null)
{
- _key = "";
+ key = "";
System.err.println("STOP.KEY system property must be specified");
System.err.println("Using empty key");
}
- try (Socket s = new Socket(InetAddress.getByName("127.0.0.1"),_port))
+ try (Socket s = new Socket(InetAddress.getByName(host),port))
{
if (timeout > 0)
{
@@ -500,7 +501,7 @@ public class Main
try (OutputStream out = s.getOutputStream())
{
- out.write((_key + "\r\nstop\r\n").getBytes());
+ out.write((key + "\r\nstop\r\n").getBytes());
out.flush();
if (timeout > 0)
diff --git a/jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt b/jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt
index 0817b46738..eacb16b620 100644
--- a/jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt
+++ b/jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt
@@ -108,6 +108,10 @@ Startup / Shutdown Command Line:
Properties:
+ STOP.HOST=[string]
+ The host to use to stop the running Jetty server (defaults to 127.0.0.1)
+ Required along with STOP.PORT if you want to use the --stop option above.
+
STOP.PORT=[number]
The port to use to stop the running Jetty server.
Required along with STOP.KEY if you want to use the --stop option above.

Back to the top