正如ZooKeeper的文檔中所說的,有必要使用daemontools等工具來監督它。但是文檔沒有提供任何示例,我知道啓動ZooKeeper的唯一方法是運行bin/zkServer.sh start。我打算使用supervisord來完成這項工作,但如何編寫[program:zookeeper]部分超出了我的想象。任何例子都會很棒。謝謝。Supervisise ZooKeeper with Supervisord
到目前爲止,是兩種解決方法:
- 使用從GitHub最新的代碼,它提供stopasgroup和killasgroup選項。
- 執行bin/zkServer.sh print-cmd,並將輸出複製到supervisord的'command'選項,移除管道參數並添加stdout_logfile,stderr_logfile。如下所示:
[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
[supervisord停止子進程]的可能的副本(http://stackoverflow.com/questions/9090683/supervisord-stopping-child-processes) – 2012-08-16 09:38:09