Allow to run the shutdown on another IP that localhost.
authorjfclere <jfclere@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 12 Feb 2008 16:22:58 +0000 (16:22 +0000)
committerjfclere <jfclere@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 12 Feb 2008 16:22:58 +0000 (16:22 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@620845 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/Server.java
java/org/apache/catalina/core/StandardServer.java
java/org/apache/catalina/startup/Catalina.java

index 014f6fd..917526d 100644 (file)
@@ -89,6 +89,20 @@ public interface Server {
 
 
     /**
+     * Return the address on which we listen to for shutdown commands.
+     */
+    public String getAddress();
+
+
+    /**
+     * Set the address on which we listen to for shutdown commands.
+     *
+     * @param address The new address
+     */
+    public void setAddress(String address);
+
+
+    /**
      * Return the shutdown command string we are waiting for.
      */
     public String getShutdown();
index 155f7cf..7135ae9 100644 (file)
@@ -137,6 +137,11 @@ public final class StandardServer
      */
     private int port = 8005;
 
+    /**
+     * The address on which we wait for shutdown commands.
+     */
+    private String address = "127.0.0.1";
+
 
     /**
      * A random number generator that is <strong>only</strong> used if
@@ -281,6 +286,27 @@ public final class StandardServer
 
 
     /**
+     * Return the address on which we listen to for shutdown commands.
+     */
+    public String getAddress() {
+
+        return (this.address);
+
+    }
+
+
+    /**
+     * Set the address on which we listen to for shutdown commands.
+     *
+     * @param address The new address
+     */
+    public void setAddress(String address) {
+
+        this.address = address;
+
+    }
+
+    /**
      * Return the shutdown command string we are waiting for.
      */
     public String getShutdown() {
@@ -372,9 +398,10 @@ public final class StandardServer
         try {
             serverSocket =
                 new ServerSocket(port, 1,
-                                 InetAddress.getByName("127.0.0.1"));
+                                 InetAddress.getByName(address));
         } catch (IOException e) {
             log.error("StandardServer.await: create[" + port
+                               + ":" + address
                                + "]: ", e);
             System.exit(1);
         }
index 415f75a..d8c1813 100644 (file)
@@ -416,7 +416,7 @@ public class Catalina extends Embedded {
 
         // Stop the existing server
         try {
-            Socket socket = new Socket("127.0.0.1", server.getPort());
+            Socket socket = new Socket(server.getAddress(), server.getPort());
             OutputStream stream = socket.getOutputStream();
             String shutdown = server.getShutdown();
             for (int i = 0; i < shutdown.length(); i++)