Supervise ZooKeeper with Supervisord

Ji ZHANG picture Ji ZHANG · Aug 16, 2012 · Viewed 8.3k times · Source

As is said in ZooKeeper's doc, it's necessary to supervise it with a tool like daemontools. But the doc doesn't provide any examples, and the only way I know to start ZooKeeper is running bin/zkServer.sh start. I plan to use supervisord to do the job, but how to write the [program:zookeeper] section is beyond me. Any example will be great. Thanks.

So far there're two solutions:

  1. use the latest code from github, it provides stopasgroup and killasgroup options.
  2. execute bin/zkServer.sh print-cmd, and copy the output to supervisord's 'command' options, remove the pipe argument, and add stdout_logfile, stderr_logfile. Like the following:
    [program:zookeeper]
    command = /usr/lib/jvm/java-1.7.0-openjdk.x86_64/bin/java -Dzookeeper.log.dir="." -Dzookeeper.root.logger="INFO,CONSOLE" -cp "/home/jizhang/Applications/zookeeper/bin/../build/classes:/home/jizhang/Applications/zookeeper/bin/../build/lib/*.jar:/home/jizhang/Applications/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/home/jizhang/Applications/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/home/jizhang/Applications/zookeeper/bin/../lib/netty-3.2.2.Final.jar:/home/jizhang/Applications/zookeeper/bin/../lib/log4j-1.2.15.jar:/home/jizhang/Applications/zookeeper/bin/../lib/jline-0.9.94.jar:/home/jizhang/Applications/zookeeper/bin/../zookeeper-3.4.3.jar:/home/jizhang/Applications/zookeeper/bin/../src/java/lib/*.jar:/home/jizhang/Applications/zookeeper/bin/../conf:"   -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain "/home/jizhang/Applications/zookeeper/bin/../conf/zoo.cfg"
    stdout_logfile = /home/jizhang/Applications/zookeeper/zookeeper.out
    stderr_logfile = /home/jizhang/Applications/zookeeper/zookeeper.err
    autorestart = true

Answer

sbridges picture sbridges · Aug 16, 2012

There is a similar question here

[program:zookeeper]
command=zkServer.sh start-foreground
autorestart=true
stopsignal=KILL

That question mentions a problem killing the process, and I am not sure if there is a solution yet.