Skip to content

Instantly share code, notes, and snippets.

@nathanstoll
Created December 11, 2011 21:22
Show Gist options
  • Save nathanstoll/1462820 to your computer and use it in GitHub Desktop.
Save nathanstoll/1462820 to your computer and use it in GitHub Desktop.
Enable memcached daemon built into Mac OSX Lion.
<?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>/usr/bin/memcached</string>
<string>-l</string> <string>127.0.0.1</string>
<string>-t</string> <string>4</string>
<string>-m</string> <string>64</string>
</array>
<key>Disabled</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>UserName</key>
<string>daemon</string>
<key>GroupName</key>
<string>daemon</string>
</dict>
</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>/usr/bin/memcached</string>
<string>-l</string> <string>127.0.0.1</string>
<string>-t</string> <string>4</string>
<string>-m</string> <string>64</string>
</array>
<key>Disabled</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>UserName</key>
<string>daemon</string>
<key>GroupName</key>
<string>daemon</string>
</dict>
</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>/usr/bin/memcached</string>
<string>-u</string> <string>nobody</string>
<string>-p</string> <string>11211</string>
<string>-t</string> <string>4</string>
<string>-m</string> <string>64</string>
<string>-c</string> <string>10240</string>
</array>
<key>Disabled</key>
<false/>
<key>KeepAlive</key>
<true/>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>daemon</string>
<key>GroupName</key>
<string>daemon</string>
</dict>
</plist>
# Make a backup of /System/Library/LaunchDaemons/com.danga.memcached.plist
sudo cp /System/Library/LaunchDaemons/com.danga.memcached.plist.original
# Edit the plist and copy/paste the new version in
sudo emacs /System/Library/LaunchDaemons/com.danga.memcached.plist
# make sure it is unloaded
sudo launchctl unload /System/Library/LaunchDaemons/com.danga.memcached.plist
# load / launch it
sudo launchctl load /System/Library/LaunchDaemons/com.danga.memcached.plist
# Voila, all the settings are the same as with the port install of memcached.
# Find out what settings it is running with using the following:
echo "stats settings" | nc localhost 11211
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd" >
<plist version='1.0'>
<dict>
<key>Label</key><string>org.macports.memcached</string>
<key>ProgramArguments</key>
<array>
<string>/opt/local/bin/daemondo</string>
<string>--label=memcached</string>
<string>--start-cmd</string>
<string>/opt/local/bin/memcached</string>
<string>-u</string>
<string>nobody</string>
<string>-m</string>
<string>64</string>
<string>-c</string>
<string>10240</string>
<string>-p</string>
<string>11211</string>
<string>;</string>
<string>--pid=exec</string>
</array>
<key>Debug</key><false/>
<key>Disabled</key><true/>
<key>OnDemand</key><false/>
</dict>
</plist>
@nathanstoll
Copy link
Author

I found that this config of memcached differed from the port install of memcached, and want them to be the same so that members of a team on SnowLeopard and Lion can both use similar memcached configs.

@nathanstoll
Copy link
Author

If you want to understand what these memcached config options do, read here:
http://code.google.com/p/memcached/wiki/NewConfiguringServer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment