【问题标题】:Get Zookeeper started automatically in OS X Yosemite using launchd使用 launchd 在 OS X Yosemite 中自动启动 Zookeeper
【发布时间】:2015-06-24 18:09:08
【问题描述】:

正如标题所说,我正在尝试在 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”来检查服务时,实际服务不存在,如果我手动启动zookeeper,我通常会看到"sudo /opt/zookeeper/bin/zkServer.sh 启动"

有人可以帮助我吗?谢谢。

【问题讨论】:

    标签: daemon apache-zookeeper launchd osx-yosemite launchdagent


    【解决方案1】:

    我有一个简单的 ping 由 launchd 运行,我会得到

    会话采用只允许在用户域中。

    在系统日志中 -- 并且该进程不会运行。

    我的猜测是由于日志中的问题而被阻止。


    如果您执行 launchctl list |grepplist name 并且它在第一列中显示 -(应该是 PID),那么作业永远不会运行。

    下面是一个运行 bash 脚本的工作 plist示例。

    #launchctl list |grep ping

    549 0 com.pingServers

    【讨论】:

      猜你喜欢
      • 2015-01-06
      • 2014-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-15
      • 1970-01-01
      • 2014-12-13
      • 2015-01-28
      相关资源
      最近更新 更多