Browse files

change to bash from sh to support macosx which doesn't handle echo -n…

… with sh, removed use of fuser as it's not available on macosx, use pid files/kill instead
  • Loading branch information...
1 parent 4e74c68 commit 4ec1e1d5840c4a28db9d8b2d13c34fa460fc7cf8 @phunt committed Dec 8, 2009
Showing with 19 additions and 8 deletions.
  1. +3 −1 start.tmpl
  2. +11 −2 stop.tmpl
  3. +5 −5 zkconf.py
View
4 start.tmpl
@@ -1,5 +1,7 @@
-#!/bin/sh
+#!/bin/bash
#for $sid, $servername, $clientport, $port1, $port2 in $serverlist
java -cp log4j.jar:zookeeper.jar:. org.apache.zookeeper.server.quorum.QuorumPeerMain ./$servername:$clientport/zoo.cfg > ./$servername:$clientport/zoo.log 2>&1 &
+echo -n $! > ./$servername:$clientport/zookeeper_server.pid
+
#end for
View
13 stop.tmpl
@@ -1,5 +1,14 @@
-#!/bin/sh
+#!/bin/bash
#for $sid, $servername, $clientport, $port1, $port2 in $serverlist
-fuser -k -n tcp $clientport
+PIDFILE=./$servername:$clientport/zookeeper_server.pid
+
+if [ -e "\$PIDFILE" ]
+then
+ kill -9 \$(cat \$PIDFILE)
+ rm \$PIDFILE
+else
+ echo "Missing \$PIDFILE, not stopping respective server"
+fi
+
#end for
View
10 zkconf.py
@@ -122,17 +122,17 @@ def writescript(name, content):
writescript("start.sh", str(start(searchList=[{'serverlist' : serverlist}])))
writescript("stop.sh", str(stop(searchList=[{'serverlist' : serverlist}])))
- content = """#!/bin/sh
+ content = """#!/bin/bash
java -cp zookeeper.jar:log4j.jar:. org.apache.zookeeper.ZooKeeperMain -server "$1"\n"""
writescript("cli.sh", content)
- content = '#!/bin/sh\n'
+ content = '#!/bin/bash\n'
for sid in xrange(1, len(options.servers) + 1) :
- content += ('echo -n "' + options.servers[sid - 1] +
+ content += ('echo "' + options.servers[sid - 1] +
":" + str(options.clientports[sid - 1]) + ' "' +
- ';echo stat | nc ' + options.servers[sid - 1] +
+ ' $(echo stat | nc ' + options.servers[sid - 1] +
" " + str(options.clientports[sid - 1]) +
- ' | egrep "Mode: "\n')
+ ' | egrep "Mode: ")\n')
writescript("status.sh", content)
try:

0 comments on commit 4ec1e1d

Please sign in to comment.