浏览代码

ZOOKEEPER-1625. zkServer.sh is looking for clientPort in config file, but it may
no longer be there with ZK-1411 (Alexander Shraer via michim)


git-svn-id: https://svn.apache.org/repos/asf/zookeeper/trunk@1437257 13f79535-47bb-0310-9956-ffa450edef68

Michi Mutsuzaki 12 年之前
父节点
当前提交
36b1c43ea1
共有 2 个文件被更改,包括 18 次插入1 次删除
  1. 3 0
      CHANGES.txt
  2. 15 1
      bin/zkServer.sh

+ 3 - 0
CHANGES.txt

@@ -301,6 +301,9 @@ BUGFIXES:
 
   ZOOKEEPER-1597. Windows build failing (michim via phunt)
 
+  ZOOKEEPER-1625. zkServer.sh is looking for clientPort in config file, but it
+  may no longer be there with ZK-1411 (Alexander Shraer via michim)
+
 IMPROVEMENTS:
 
   ZOOKEEPER-1170. Fix compiler (eclipse) warnings: unused imports,

+ 15 - 1
bin/zkServer.sh

@@ -173,9 +173,23 @@ restart)
     ;;
 status)
     # -q is necessary on some versions of linux where nc returns too quickly, and no stat result is output
+    clientPort=`grep "^[[:space:]]*clientPort" "$ZOOCFG" | sed -e 's/.*=//'`
+    if ! [ $clientPort ]
+    then
+       echo "Client port not found in static config file. Looking in dynamic config file."
+       dataDir=`grep "^[[:space:]]*dataDir" "$ZOOCFG" | sed -e 's/.*=//'`
+       myid=`cat "$dataDir/myid"`
+       dynamicConfigFile=`grep "^[[:space:]]*dynamicConfigFile" "$ZOOCFG" | sed -e 's/.*=//'`
+       clientPort=`grep "^[[:space:]]*server.$myid" "$dynamicConfigFile" | sed -e 's/.*=//' | sed -e 's/.*;//' | sed -e 's/.*://'`
+       if ! [[ "$clientPort" =~ ^[0-9]+$ ]] ; then
+          echo "Client port not found. Terminating."
+          exit 1
+       fi
+    fi
+    echo "Client port found: $clientPort"
     STAT=`$JAVA "-Dzookeeper.log.dir=${ZOO_LOG_DIR}" "-Dzookeeper.root.logger=${ZOO_LOG4J_PROP}" \
              -cp "$CLASSPATH" $JVMFLAGS org.apache.zookeeper.client.FourLetterWordMain localhost \
-             $(grep "^[[:space:]]*clientPort" "$ZOOCFG" | sed -e 's/.*=//') srvr 2> /dev/null    \
+             $clientPort srvr 2> /dev/null    \
           | grep Mode`
     if [ "x$STAT" = "x" ]
     then