gorn.ch

Tobias Ebnöther's personal blog

Start memcached with launchd [Updated]

I let memcached automatically start with the OS X integrated launchd. Here is the XML I provided to start it with the following settings:

  • Bound to localhost
  • Runs as nobody
  • Spawns only one thread (this can slow things down)
  • Consume a maximum of 10MB memory (it will just throw old stuff out afterwards)
  • It will start when you login
  • It will send all output to /dev/null

Here is the updated script (I use macports now instead of fink just change the path to wherever your binary is). Just put the XML to ~/Library/LaunchAgents/memcached.plist and run launchctl load ~/Library/LaunchAgents/memcached.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>Label</key>
    <string>memcached</string>
    <key>ProgramArguments</key>
    <array>
        <string>/opt/local/bin/memcached</string>
        <string>-l</string>
        <string>127.0.0.1</string>
        <string>-u</string>
        <string>nobody</string>
        <string>-t</string>
        <string>1</string>
        <string>-m</string>
        <string>10</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>StandardOutPath</key>
    <string>/dev/null</string>
    <key>StandardErrorPath</key>
    <string>/dev/null</string>
</dict>
</plist>
Related Entries:
Start memcached with SystemStarter
Comments (3)  Permalink

Comments

Philip Plante @ 14.03.2008 03:51 CET
This is very helpful for me. The only launchd scripts I could find were for 10.4.

Thank you!
ebi @ 14.03.2008 08:52 CET
Glad to help you :) This should be running ob both Tiger & Leopard.
Vincent Bray @ 11.07.2009 11:10 CET
Thanks for this. Just wanted to point out that the process won't run as nobody unless you use the system wide Launch(Agent/Daemon) path.
No new comments allowed (anymore) on this post.
Powered by Flux CMS