launchctl kickstart "Could Not Find Service" Until Reboot
We recently found that launchd/launchctl changed with 10.10 and so we're refactoring things to work with the non-legacy commands. What I'm seeing during my testing is that after I bootstrap and enable the service (The service is disabled via an entry in the plist on purpose) I can't kickstart it...The command always fails with:
Could not find service "com.monetra.service" in domain for system
I've tried restarting the terminal and logging off and then back on again and same results...However, once I reboot it works.
Here are the steps that I'm taking:
Create plist file:
cat > /Library/LaunchDaemons/monetra.plist << 'EOF'
<?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>Label</key>
<string>com.monetra.service</string>
<key>Program</key>
<string>/usr/local/monetra/bin/monetra.sh</string>
<key>Disabled</key>
<true/>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOF
Change permissions on plist file:
chmod 600 /Library/LaunchDaemons/monetra.plist
Bootstrap plist file:
launchctl bootstrap system /Library/LaunchDaemons/monetra.plist
Enable service:
launchctl enable system/com.monetra.service
Kickstart service:
launchctl kickstart system/com.monetra.service
Again, after I reboot the service starts up automatically, and I can kill then kickstart as expected...Seems like it's not available until the system reboots, which is puzzling. I've tried this on 10.11 and 10.12 and both display same behavior, have not tried it on 10.10
And before anyone asks, we have to have it disabled in the plist as our software can't run right correctly until some post-install steps have been done. For whatever reason if we don't have the disable in the plist when we bootstrap the service just fires up...Which makes no sense.
OS X El Capitan (10.11.6)