0

I have a launchd daemon definition

/Library/LaunchDaemons/homebrew.mxcl.docker-machine.plist

which contains:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>EnvironmentVariables</key>
    <dict>
        <key>PATH</key>
        <string>/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin</string>
    </dict>
    <key>Label</key>
    <string>homebrew.mxcl.docker-machine</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/opt/docker-machine/bin/docker-machine</string>
        <string>start</string>
        <string>default</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
    <key>UserName</key>
    <string>sysbh</string>
    <key>WorkingDirectory</key>
    <string>/Users/sysbh</string>
  </dict>
</plist>

At boot time, this does not work. But when logged in, I can get it to run with sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.docker-machine.plist

Any tips what I can do to find out why the launchd plist doesn't get the program started during boot/startup, but does later?

And suppose (which is a distinct possibility) that this daemon depends on another launchd daemon having been run first (and to make it complicated: that daemon only runs once to install kexts), is there a way around that problem?

  • Did it get disabled? Try sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.docker-machine.plist (note the -w). – Gordon Davisson Jan 10 at 22:27
  • Are you sure it's not being launched, or could it just be failing? If it keeps failing, KeepAlive will use a 10-second cooldown before relaunching. A few more ideas: is sysbh your user? If so, is your home directory encrypted? That would stop it from working until you logged in. Also, if this is your user, would it not be better to implement this as a Launch Agent? (put the launchd plist in ~/Library/LaunchAgents/) – pmdj Jan 11 at 12:53
  • Finally, you mention a kext dependency; you can make Launch Daemons and Agents launch when an IOKit node is matched. However, the agent binary must respond to that message. So this will only work if your kext publishes a node in the IORegistry, and if docker-machine can handle the generated IOKit matching XPC event. – pmdj Jan 11 at 12:53
  • No, it did not get Disabled and I do not need the -w flag to make it work from the command line. The disk is FileVaulted, but at the point the daemons are loaded it has been decrypted already (required for boot). It is clear that the command fails during boot time, but not later when loaded by hand. It should not be a LaunchAgent as it must start before anyone logs in, it is just that I don't want that process to run with root privileges for security reasons, so I'm using another user. How do I find out if the kext publishes that node? – gctwnl Jan 11 at 23:11

You must log in to answer this question.

Browse other questions tagged .