Skip to content

Instantly share code, notes, and snippets.

@gmanley
Created April 19, 2012 15:34
Show Gist options
  • Save gmanley/2421766 to your computer and use it in GitHub Desktop.
Save gmanley/2421766 to your computer and use it in GitHub Desktop.
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist
rm -f ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist
brew uninstall memcached
brew install https://raw.github.com/gist/2421766/1a210dbd360486631ff4fb22fd74a0eed5983d91/memcached.rb
cp /usr/local/Cellar/memcached/1.4.13/homebrew.mxcl.memcached.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist
tail -f /usr/local/var/log/memcached.log
require 'formula'
class Memcached < Formula
url "http://memcached.googlecode.com/files/memcached-1.4.13.tar.gz"
homepage 'http://memcached.org/'
sha1 'd9a48d222de53a2603fbab6156d48d0e8936ee92'
depends_on 'libevent'
def options
[
["--enable-sasl", "Enable SASL support -- disables ASCII protocol!"],
["--enable-sasl-pwdb", "Enable SASL with memcached's own plain text password db support -- disables ASCII protocol!"],
]
end
def install
args = ["--prefix=#{prefix}"]
args << "--enable-sasl" if ARGV.include? "--enable-sasl"
args << "--enable-sasl-pwdb" if ARGV.include? "--enable-sasl-pwdb"
system "./configure", *args
system "make install"
plist_path.write startup_plist
plist_path.chmod 0644
end
def caveats; <<-EOS.undent
You can enable memcached to automatically load on login with:
mkdir -p ~/Library/LaunchAgents
cp #{plist_path} ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
If this is an upgrade and you already have the #{plist_path.basename} loaded:
launchctl unload -w ~/Library/LaunchAgents/#{plist_path.basename}
cp #{plist_path} ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
Or start it manually:
#{HOMEBREW_PREFIX}/bin/memcached
Add "-d" to start it as a daemon.
To see the log run the following:
tail -f /usr/local/var/log/memcached.log
EOS
end
def startup_plist
return <<-EOPLIST
<?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>#{plist_name}</string>
<key>KeepAlive</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>#{HOMEBREW_PREFIX}/bin/memcached</string>
<string>-l</string>
<string>localhost</string>
<string>-vvv &gt; /usr/local/var/log/memcached.log 2&gt;&amp;1</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{HOMEBREW_PREFIX}</string>
</dict>
</plist>
EOPLIST
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment