homebrew-core/Formula/varnish.rb
2017-10-20 23:20:34 -07:00

69 lines
2.3 KiB
Ruby

class Varnish < Formula
desc "High-performance HTTP accelerator"
homepage "https://www.varnish-cache.org/"
url "https://varnish-cache.org/_downloads/varnish-5.2.0.tgz"
sha256 "cc4826a0480f49268d3996309e4b7e465151e9a523ccf8ead499ec575149f47e"
bottle do
sha256 "5512f0894c01aa13ac5f46c97cc0ea92d91e3762499065871d033fb48da509fb" => :high_sierra
sha256 "4f258821e068b2f83718a7ead9cfaf7d1d89bd2880bc7e389429815b04668ef8" => :sierra
sha256 "25482a24178cf87aacaa447bd3b6c37346e495d502107795b600805ecfb98a53" => :el_capitan
end
depends_on "pkg-config" => :build
depends_on "docutils" => :build
depends_on "pcre"
def install
system "./configure", "--disable-dependency-tracking",
"--prefix=#{prefix}",
"--localstatedir=#{var}"
system "make", "install"
(etc+"varnish").install "etc/example.vcl" => "default.vcl"
(var+"varnish").mkpath
end
plist_options :manual => "#{HOMEBREW_PREFIX}/sbin/varnishd -n #{HOMEBREW_PREFIX}/var/varnish -f #{HOMEBREW_PREFIX}/etc/varnish/default.vcl -s malloc,1G -T 127.0.0.1:2000 -a 0.0.0.0:8080 -F"
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>ProgramArguments</key>
<array>
<string>#{opt_sbin}/varnishd</string>
<string>-n</string>
<string>#{var}/varnish</string>
<string>-f</string>
<string>#{etc}/varnish/default.vcl</string>
<string>-s</string>
<string>malloc,1G</string>
<string>-T</string>
<string>127.0.0.1:2000</string>
<string>-a</string>
<string>0.0.0.0:8080</string>
<string>-F</string>
</array>
<key>KeepAlive</key>
<true/>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{HOMEBREW_PREFIX}</string>
<key>StandardErrorPath</key>
<string>#{var}/varnish/varnish.log</string>
<key>StandardOutPath</key>
<string>#{var}/varnish/varnish.log</string>
</dict>
</plist>
EOS
end
test do
assert_match version.to_s, shell_output("#{sbin}/varnishd -V 2>&1")
end
end