[launchd-dev] Launching a process on demand?

Conrad Taylor conradwt at gmail.com
Tue Jul 7 01:25:21 PDT 2009


On Mon, Jul 6, 2009 at 11:45 PM, Damien Sorresso <dsorresso at apple.com>wrote:

> On Jul 6, 2009, at 10:11 PM, Conrad Taylor wrote:
>
>> Hi, I'm attempting to configure the MySQL launchd plist file to launch
>> MySQL process only when needed.  At this time, it's launched at boot/startup
>> and it stays alive.  At this time, the script looks as follows:
>>
>> BEGIN org.macports.mysql5.plist:
>>
>> <?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>Debug</key>
>>        <false/>
>>        <key>Label</key>
>>        <string>org.macports.mysql5</string>
>>        <key>OnDemand</key>
>>        <false/>
>>        <key>ProgramArguments</key>
>>        <array>
>>                <string>/opt/local/bin/daemondo</string>
>>                <string>--label=mysql5</string>
>>                <string>--start-cmd</string>
>>
>>  <string>/opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper</string>
>>                <string>start</string>
>>                <string>;</string>
>>                <string>--stop-cmd</string>
>>
>>  <string>/opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper</string>
>>                <string>stop</string>
>>                <string>;</string>
>>                <string>--restart-cmd</string>
>>
>>  <string>/opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper</string>
>>                <string>restart</string>
>>                <string>;</string>
>>                <string>--pid=none</string>
>>        </array>
>>        <key>RunAtLoad</key>
>>        <false/>
>> </dict>
>> </plist>
>>
>> END org.macports.mysql5.plist:
>>
>
> When you start inserting semi-colons into your ProgramArguments, it's time
> to wrap it all up in a simple shell script.
>
>  I changed the above key/value pair to OnDemand/true.  Now, the process
>> doesn't start when I try to access it by doing the following:
>>
>
> OnDemand is deprecated. If you want the job launched on-demand, you can
> define a Sockets dictionary or a MachServices dictionary. Though since
> you're dealing with MySQL, I'm guessing you want the former. To see an
> example of a job that's launched on-demand when there is a connection to a
> socket, check out the SampleD example and BetterAuthorizationSample.
>
>  Is there a manual which clearly describes these key/value pairs?  I guess
>> I'm interested in the key/value pair, OnDemand, and when/how it works.
>>
>
> launchd.plist(5)
> --
> Damien Sorresso
> BSD Engineering
> Apple Inc.
>
>
Yes, I read that OnDemand switch to KeepAlive in Mac OS 10.5.  Also, the
above is the default plist MySQL port which is wrapped in a script
called mysql5.wrapper.  In any case, I'll take a look at the samples and
thanks for the information.

-Conrad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/launchd-dev/attachments/20090707/ce4f657e/attachment-0001.html>


More information about the launchd-dev mailing list