homebrew-core/Formula/memcached.rb
2019-11-26 12:35:06 +00:00

56 lines
1.8 KiB
Ruby

class Memcached < Formula
desc "High performance, distributed memory object caching system"
homepage "https://memcached.org/"
url "https://www.memcached.org/files/memcached-1.5.20.tar.gz"
sha256 "cfd7b023a9cefe7ae8a67184f51d841dbbf97994ed0e8a55e31ee092320ea1e4"
bottle do
cellar :any
sha256 "05de923c87cb0d12390feada34fd8b752cbb5bf52b2c83ced908831cda3b8bb5" => :catalina
sha256 "b68bfc7f3baf04186076d3ef62480057a6f835ac351b68615412be4e32817200" => :mojave
sha256 "f9af5560fd1dde5a254f84b020808bea2d327993edc012773f58090eb116d86b" => :high_sierra
end
depends_on "libevent"
def install
system "./configure", "--prefix=#{prefix}", "--disable-coverage"
system "make", "install"
end
plist_options :manual => "#{HOMEBREW_PREFIX}/opt/memcached/bin/memcached"
def plist; <<~EOS
<?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>#{opt_bin}/memcached</string>
<string>-l</string>
<string>localhost</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{HOMEBREW_PREFIX}</string>
</dict>
</plist>
EOS
end
test do
pidfile = testpath/"memcached.pid"
# Assumes port 11211 is not already taken
system bin/"memcached", "--listen=localhost:11211", "--daemon", "--pidfile=#{pidfile}"
sleep 1
assert_predicate pidfile, :exist?, "Failed to start memcached daemon"
pid = (testpath/"memcached.pid").read.chomp.to_i
Process.kill "TERM", pid
end
end