saltstack/salt — pull request #4482 by jasonrm (2013-04-13 03:41:24+00:00)
Title: Fix stop/start and add plist support to launchctl module.

Currently the launchctl module is unable to manage a service that is not already loaded, nor does it start and stop a service correctly. In order to support unloaded plists, all plists have to be read on first access to most methods in the launchctl module. This is because we don't know if all label in each plist file matches its filename. Usually they do, however it's not guaranteed. Also, not all plist files are XML, some are binary or JSON. Thankfully we have the `plutil` tool provided by the system for doing conversions.

Launchctl `stop` is not the same as stop on most systems. It will kill the process, however most services will start up again as it's very common for a service to have both `RunAtLoad` and `KeepAlive` set in the services plist file.

Similarly, `start` start will only start a service that has previously been loaded without the `RunAtLoad` key in the service plist. The man page for `launchctl` also notes that expected usage of `start` is for debugging and testing.

These changes do not find per-user `~/Library/LaunchAgents` services at the current time.