class RedisAT32 < Formula desc "Persistent key-value database, with built-in net interface" homepage "https://redis.io/" url "http://download.redis.io/releases/redis-3.2.11.tar.gz" sha256 "31ae927cab09f90c9ca5954aab7aeecc3bb4da6087d3d12ba0a929ceb54081b5" head "https://github.com/antirez/redis.git", :branch => "3.2" bottle do cellar :any_skip_relocation sha256 "c2b89b227eacd40e8f3d0ad2f8b01509a1f182252e1b91b36a5256a40649b70c" => :high_sierra sha256 "78f7a36a2e4ac2bf8d5efdb70e9ac84eb50d9e6ce815d8c4d25e1268ce67aa5a" => :sierra sha256 "a73d084f4aef70d0f7c614317c66cb9ca55614ccb2363f62af59276d431ee3e0" => :el_capitan end keg_only :versioned_formula 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 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_predicate var/p, :exist?, "#{var/p} doesn't exist!" } end end