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.