class Redis < Formula desc "Persistent key-value database, with built-in net interface" homepage "https://redis.io/" url "http://download.redis.io/releases/redis-4.0.0.tar.gz" sha256 "d539ae309295721d5c3ed7298939645b6f86ab5d25fdf2a0352ab575c159df2d" head "https://github.com/antirez/redis.git", :branch => "unstable" bottle do cellar :any_skip_relocation sha256 "dd8b0819b04b1ec99260892d0e597714b8806e5e3a84ff0af01779f2304d7cb8" => :sierra sha256 "d4106182b2e7e0d41cea54c9a5b09bb0d7f93cbac8478db5a70dbc7d886378ad" => :el_capitan sha256 "45783be0561aa0bd4698a07d65dbf9874a25becb4d450cdb6a3085600cbae814" => :yosemite end option "with-jemalloc", "Select jemalloc as memory allocator when building Redis" def install # Architecture isn't detected correctly on 32bit Snow Leopard without help ENV["OBJARCH"] = "-arch #{MacOS.preferred_arch}" args = %W[ PREFIX=#{prefix} CC=#{ENV.cc} ] args << "MALLOC=jemalloc" if build.with? "jemalloc" system "make", "install", *args %w[run db/redis log].each { |p| (var/p).mkpath } # Fix up default conf file to match our paths inreplace "redis.conf" do |s| s.gsub! "/var/run/redis.pid", var/"run/redis.pid" s.gsub! "dir ./", "dir #{var}/db/redis/" s.gsub! "\# bind 127.0.0.1", "bind 127.0.0.1" end etc.install "redis.conf" etc.install "sentinel.conf" => "redis-sentinel.conf" end plist_options :manual => "redis-server #{HOMEBREW_PREFIX}/etc/redis.conf" def plist; <<-EOS.undent KeepAlive SuccessfulExit Label #{plist_name} ProgramArguments #{opt_bin}/redis-server #{etc}/redis.conf --daemonize no RunAtLoad WorkingDirectory #{var} StandardErrorPath #{var}/log/redis.log StandardOutPath #{var}/log/redis.log EOS end test do system bin/"redis-server", "--test-memory", "2" %w[run db/redis log].each { |p| assert (var/p).exist?, "#{var/p} doesn't exist!" } end end