1. Andy Gross
  2. riak_rabbit

Commits

dizzyd  committed 38f95fd

Update riak-admin to invoke proper variation of service listing; provide a better error message if services retrieval fails

  • Participants
  • Parent commits 674904b
  • Branches default

Comments (0)

Files changed (1)

File rel/files/riak-admin

View file
 
     wait-for-service)
         SVC=$2
-        if [ $# -lt 2 ]; then
-            echo "Usage: $SCRIPT wait-for-service <service_name>"
+        TARGETNODE=$3
+        if [ $# -lt 3 ]; then
+            echo "Usage: $SCRIPT wait-for-service <service_name> <target_node>"
             exit 1
         fi
 
         while (true); do
-            RES=`$NODETOOL rpcterms riak_core_node_watcher services ''| grep $SVC`
-            if [ ! -z "$RES" ]; then
+            # Make sure riak_core_node_watcher is up and running locally before trying to query it
+            # to avoid ugly (but harmless) error messages
+            NODEWATCHER=`$NODETOOL rpcterms erlang whereis "'riak_core_node_watcher'."`
+            if [ "$NODEWATCHER" == "undefined" ]; then
+                echo "$SVC is not up: node watcher is not running"
+                continue
+            fi
+
+            # Get the list of services that are available on the requested noe
+            SERVICES=`$NODETOOL rpcterms riak_core_node_watcher services "'${TARGETNODE}'."`
+            echo "$SERVICES" | grep "$SVC" > /dev/null 2>&1
+            if [ "X$?" = "X0" ]; then
                 echo "$SVC is up"
                 exit 0
             else
-                echo "$SVC is not up"
+                echo "$SVC is not up: $SERVICES"
             fi
             sleep 3
         done