就像标题所说的那样,我正在尝试在 OS X Yosemite 中使用 launchd/launchctl 自动启动 zookeeper。
这是我的 plist 文件“/Library/LaunchDaemons/com.test.zookeeper.plist”,它归 root:wheel 所有。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.test.zookeeper</string>
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/opt/zookeeper/bin/zkServer.sh</string>
<string>start</string>
</array>
<key>StandardInPath</key>
<string>/var/log/zookeeper_stdin.log</string>
<key>StandardOutPath</key>
<string>/var/log/zookeeper_stdout.log</string>
<key>StandardErrorPath</key>
<string>/var/log/zookeeper_stderr.log</string>
</dict>
</plist>
执行“sudo launchctl load com.test.zookeeper.plist”后,这是“/var/log/system.log”中的内容,用户名已替换为星号。
Apr 17 11:13:22 ***-03 sudo[97284]: ****.** : TTY=ttys003 ; PWD=/Library/LaunchDaemons ; USER=root ; COMMAND=/bin/launchctl load com.test.zookeeper.plist
Apr 17 11:13:22 ***-03 com.apple.xpc.launchd[1] (com.apple.xpc.launchd.domain.system): Session adoption is only allowed in user domains.
Apr 17 11:13:22 ***-03 nohup[97299]: Could not adopt Background session: 125: Domain does not support specified action
“/var/log/zookeeper_stdout.log”
Starting zookeeper ... STARTED
“/var/log/zookeeper_stderr.log”
JMX enabled by default
Using config: /opt/zookeeper/bin/../conf/zoo.cfg
所以看起来这项工作是由launchd执行的,但是当我执行“ps -ef | grep zoo”来检查服务时,实际服务不存在,我通常会看到我是否使用“sudo / 手动启动zookeeper” opt/zookeeper/bin/zkServer.sh 启动"
有人能帮我吗?谢谢你。