incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1155377 - in /sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/app: ControlListener.java Main.java
Date Tue, 09 Aug 2011 14:11:57 GMT
Author: fmeschbe
Date: Tue Aug  9 14:11:57 2011
New Revision: 1155377

URL: http://svn.apache.org/viewvc?rev=1155377&view=rev
Log:
SLING-2175 Support LSB exit codes for the status command line option

Modified:
    sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/app/ControlListener.java
    sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/app/Main.java

Modified: sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/app/ControlListener.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/app/ControlListener.java?rev=1155377&r1=1155376&r2=1155377&view=diff
==============================================================================
--- sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/app/ControlListener.java
(original)
+++ sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/app/ControlListener.java
Tue Aug  9 14:11:57 2011
@@ -124,8 +124,8 @@ class ControlListener implements Runnabl
      * Implements the client side of the control connection sending the command
      * to check whether Sling is active.
      */
-    void statusServer() {
-        sendCommand(COMMAND_STATUS);
+    int statusServer() {
+        return sendCommand(COMMAND_STATUS);
     }
 
     // ---------- Runnable interface
@@ -211,7 +211,15 @@ class ControlListener implements Runnabl
         return null;
     }
 
-    private void sendCommand(String command) {
+    /**
+     * Sends the given command to the server indicated by the configured
+     * socket address and logs the reply.
+     *
+     * @param command The command to send
+     *
+     * @return A code indicating success of sending the command.
+     */
+    private int sendCommand(String command) {
         if (socketAddress != null) {
             Socket socket = null;
             try {
@@ -221,11 +229,14 @@ class ControlListener implements Runnabl
                 String result = readLine(socket);
                 Main.info("Sent '" + command + "' to " + socketAddress + ": "
                     + result, null);
+                return 0; // LSB code for everything's fine
             } catch (ConnectException ce) {
                 Main.info("No Sling running at " + socketAddress, null);
+                return 3; // LSB code for programm not running
             } catch (IOException ioe) {
                 Main.error("Failed sending '" + command + "' to "
                     + socketAddress, ioe);
+                return 1; // LSB code for programm dead
             } finally {
                 if (socket != null) {
                     try {
@@ -236,6 +247,7 @@ class ControlListener implements Runnabl
             }
         } else {
             Main.info("No socket address to send '" + command + "' to", null);
+            return 4; // LSB code for unknown status
         }
     }
 

Modified: sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/app/Main.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/app/Main.java?rev=1155377&r1=1155376&r2=1155377&view=diff
==============================================================================
--- sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/app/Main.java (original)
+++ sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/app/Main.java Tue
Aug  9 14:11:57 2011
@@ -435,8 +435,8 @@ public class Main extends Thread impleme
             sl.shutdownServer();
             System.exit(0);
         } else if (commandLineArgs.remove(ControlListener.COMMAND_STATUS) != null) {
-            sl.statusServer();
-            System.exit(0);
+            final int status = sl.statusServer();
+            System.exit(status);
         } else if (commandLineArgs.remove("start") != null) {
             sl.listen();
         }



Mime
View raw message