Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,000 hints and counting!


Click here to return to the '10.5: Control MySQL server with launchd' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
10.5: Control MySQL server with launchd
Authored by: kanenas on Fri, Apr 18 2008 at 9:39PM PDT
When added to the launchd plist, the following works for launching a MySQL server installed via MacPorts under Tiger:
<key>Sockets</key>
<dict>
        <key>MySQL-file</key>
        <dict>
                <key>SockPathName</key>
                <string>/opt/local/var/run/mysql5/mysqld.sock</string>
        </dict>
</dict>
The same should work for other instances of MySQL using UNIX sockets if you change the value of SockPathName. You might need to add a "SockPathMode" property. For IP sockets, try adding the following to the "Sockets" dict:
        <key>MySQL-net</key>
        <dict>
                <key>SockServiceName</key>
                <string>mysql</string>
        </dict>
I suspect this won't work, as launchd binds to the mysql port and MySQL servers don't AFAIK support passing sockets a la inetd.

[ Reply to This | # ]
10.5: Control MySQL server with launchd
Authored by: kanenas on Mon, Oct 6 2008 at 9:17AM PDT
Another note for Tiger users: use the "OnDemand" key rather than "KeepAlive". "OnDemand" is supported but deprecated in Leopard.

[ Reply to This | # ]
10.5: Control MySQL server with launchd
Authored by: af3556 on Wed, Jan 14 2009 at 6:59PM PST
Using the Sockets key to "on-demand" start the MySQL server only works partly and by accident. The Sockets key requires the job to use a launch API (launchd.plist.5). Using the above config causes launchd to create the socket in /tmp/mysql.sock, and when the client connects launchd notices and starts the server. The MySQL server sees that the socket exists but it doesn't expect it to, as it didn't create it, so removes it and creates its own. From then on all is business as usual. Meanwhile the first client is left hanging on a socket that has now been unlinked and won't ever be answered. This has been tested on 10.5.5, MySQL 5.0.75 installed via Macports. Also if the server exits (is shutdown or crashes), I'm not sure that launchd will recreate it. So it doesn't look like it's possible to start the mysqld server on-demand, at least until someone adds launchd support to mysql.

[ Reply to This | # ]