Can somebody please clarify how launchd's Program
and ProgramArguments
configuration parameters should be used? I tried to register a service which on the command line I'd start like this:
$ /foo/bar/baz/python /foo/bar/baz/service start
I have tried divvying that up in various ways for launchd:
<key>Program</key>
<string>/foo/bar/baz/python</string>
<key>ProgramArguments</key>
<array>
<string>/foo/bar/baz/service</string>
<string>start</string>
</array>
or
<key>Program</key>
<string>/foo/bar/baz/python</string>
<key>ProgramArguments</key>
<array>
<string>/foo/bar/baz/service start</string>
</array>
or
<key>ProgramArguments</key>
<array>
<string>/foo/bar/baz/python</string>
<string>/foo/bar/baz/service</string>
<string>start</string>
</array>
or
<key>Program</key>
<string>/bin/bash</string>
<key>ProgramArguments</key>
<array>
<string>-c</string>
<string>/foo/bar/baz/python /foo/bar/baz/service start</string>
</array>
and just about any other variation that would seem to make sense. The service always failed with various different errors though. The only thing that worked was to create a .sh script with the exact line and run that via launchd.
So, to understand launchd services once and for all: How does launchd use these two configuration parameters, how would I replicate my bash command with them and what is the difference between both?
Or am I perhaps just stumbling across a problem of running this particular service with and without some environment variables which exist when executing it via bash? The service itself did not provide any useful output.
I have consulted the execvp(3)
manual entry as advised in launchd.plist(5)
, but it did not really further my understanding.