class Caddy < Formula desc "Alternative general-purpose HTTP/2 web server" homepage "https://caddyserver.com/" url "https://github.com/caddyserver/caddy/archive/v1.0.1.tar.gz" sha256 "7cbd80c798a0db4195381f730f5409680c6e1239fbc06295b90b34f666a05692" head "https://github.com/caddyserver/caddy.git" bottle do cellar :any_skip_relocation sha256 "5e8f8e9822b41eae38560a9cfdebebfb504bc4dbd9b1bd62fc384e1f3edcee82" => :mojave sha256 "c8c1937120d718bc3b0f7ceeaac6259d300873b3bce142dea140d6952f8af255" => :high_sierra sha256 "290ffe78bdedbc9201203cd3cb473266a1477d5eb423cca25db280ef7e48e355" => :sierra end depends_on "go" => :build def install ENV["GOOS"] = "darwin" ENV["GOARCH"] = "amd64" (buildpath/"src/github.com/caddyserver").mkpath ln_s buildpath, "src/github.com/caddyserver/caddy" system "go", "build", "-ldflags", "-X github.com/caddyserver/caddy/caddy/caddymain.gitTag=#{version}", "-o", bin/"caddy", "github.com/caddyserver/caddy/caddy" end plist_options :manual => "caddy -conf #{HOMEBREW_PREFIX}/etc/Caddyfile" def plist; <<~EOS KeepAlive Label #{plist_name} ProgramArguments #{opt_bin}/caddy -conf #{etc}/Caddyfile RunAtLoad EOS end test do begin io = IO.popen("#{bin}/caddy") sleep 2 ensure Process.kill("SIGINT", io.pid) Process.wait(io.pid) end io.read =~ /0\.0\.0\.0:2015/ end end