zkServer.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/sh
  2. #
  3. # If this scripted is run out of /usr/bin or some other system bin directory
  4. # it should be linked to and not copied. Things like java jar files are found
  5. # relative to the canonical path of this script.
  6. #
  7. ZOOBIN=`readlink -f "$0"`
  8. ZOOBINDIR=`dirname "$ZOOBIN"`
  9. . $ZOOBINDIR/zkEnv.sh
  10. case $1 in
  11. start)
  12. echo -n "Starting zookeeper ... "
  13. java "-Dzookeeper.log.dir=${ZOO_LOG_DIR}" "-Dzookeeper.root.logger=${ZOO_LOG4J_PROP}" \
  14. -cp $CLASSPATH $JVMFLAGS org.apache.zookeeper.server.quorum.QuorumPeer $ZOOCFG &
  15. echo STARTED
  16. ;;
  17. stop)
  18. echo -n "Stopping zookeeper ... "
  19. echo kill | nc localhost $(grep clientPort $ZOOCFG | sed -e 's/.*=//')
  20. echo STOPPED
  21. ;;
  22. restart)
  23. shift
  24. $0 stop ${@}
  25. sleep 3
  26. $0 start ${@}
  27. ;;
  28. status)
  29. STAT=`echo stat | nc localhost $(grep clientPort $ZOOCFG | sed -e 's/.*=//') 2> /dev/null| grep Mode`
  30. if [ "x$STAT" = "x" ]
  31. then
  32. echo "Error contacting service. It is probably not running."
  33. else
  34. echo $STAT
  35. fi
  36. ;;
  37. *)
  38. echo "Usage: $0 {start|stop|restart|status}" >&2
  39. esac