Shun Y.
Shun Y.

Reputation: 103

Get Zookeeper started automatically in OS X Yosemite using launchd

Like the title said, I'm trying to launch zookeeper automatically using launchd/launchctl in OS X Yosemite.

This is my plist file "/Library/LaunchDaemons/com.test.zookeeper.plist", it's owned by 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>

after executing "sudo launchctl load com.test.zookeeper.plist", this is what's in the "/var/log/system.log", user name has been replaced with asterisks.

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

So it seems like the job was executed by launchd, but somehow the actual service is not present when I execute "ps -ef | grep zoo" to check for the service, which I would normally see if I started zookeeper manually using "sudo /opt/zookeeper/bin/zkServer.sh start"

Can someone help me? Thank you.

Upvotes: 0

Views: 838

Answers (1)

pedro
pedro

Reputation: 43

I had a simple ping being run by launchd and I would get

Session adoption is only allowed in user domains.

in the system log -- and the process would not run.

My guess is it gets blocked due to that issue in the log.


If you do launchctl list |grepplist name and it shows - in the first column (which is supposed to be a PID), then the job never ran.

Below, is an example of a working plist running a bash script.

# launchctl list |grep ping

549 0 com.pingServers

Upvotes: 0

Related Questions