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

Start memcached with SystemStarter

I used to start Memcached via launchd for a while now. Today I realized that it will use a lot (128MB) of memory after running a couple of days. I searched after a better solution and found this script which will start memcached via StartupItems/SystemStarter.

What I do now is reload Memcached every hour via launchd to purge the memory.
<?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>local.server.restartMemcached</string>
<key>ProgramArguments</key>
<array>
<string>SystemStarter</string>
<string>restart</string>
<string>Memcached</string>
</array>
<key>StartInterval</key>
<integer>3600</integer>
</dict>
</plist>
Related Entries:
Start memcached with launchd [Updated]
xchat on OSX / Command as alt
Setting up relayhost for postfix on OSX (with ssl and authentication)
MacHeist Software Bundle
Leopard native apache with custom (64bit) PHP
 Permalink
1-2/2
Powered by Flux CMS