zkServer.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. #
  3. # Licensed to the Apache Software Foundation (ASF) under one
  4. # or more contributor license agreements. See the NOTICE file
  5. # distributed with this work for additional information
  6. # regarding copyright ownership. The ASF licenses this file
  7. # to you under the Apache License, Version 2.0 (the
  8. # "License"); you may not use this file except in compliance
  9. # with the License. You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. if [ "x$1" == "x" ]
  19. then
  20. echo "USAGE: $0 startClean|start|stop hostPorts"
  21. exit 2
  22. fi
  23. if [ "x$1" == "xstartClean" ]
  24. then
  25. rm -rf /tmp/zkdata
  26. fi
  27. # Make sure nothing is left over from before
  28. if [ -r "/tmp/zk.pid" ]
  29. then
  30. pid=`cat /tmp/zk.pid`
  31. kill -9 $pid
  32. rm -f /tmp/zk.pid
  33. fi
  34. base_dir="../../../../.."
  35. CLASSPATH="$CLASSPATH:${base_dir}/build/classes"
  36. CLASSPATH="$CLASSPATH:${base_dir}/conf"
  37. for f in "${base_dir}"/zookeeper-*.jar
  38. do
  39. CLASSPATH="$CLASSPATH:$f"
  40. done
  41. for i in "${base_dir}"/build/lib/*.jar
  42. do
  43. CLASSPATH="$CLASSPATH:$i"
  44. done
  45. for i in "${base_dir}"/src/java/lib/*.jar
  46. do
  47. CLASSPATH="$CLASSPATH:$i"
  48. done
  49. CLASSPATH="$CLASSPATH:${CLOVER_HOME}/lib/clover.jar"
  50. case $1 in
  51. start|startClean)
  52. mkdir -p /tmp/zkdata
  53. java -cp $CLASSPATH org.apache.zookeeper.server.ZooKeeperServerMain 22181 /tmp/zkdata &> /tmp/zk.log &
  54. echo $! > /tmp/zk.pid
  55. sleep 5
  56. ;;
  57. stop)
  58. # Already killed above
  59. ;;
  60. *)
  61. echo "Unknown command " + $1
  62. exit 2
  63. esac