class Caddy < Formula desc "Alternative general-purpose HTTP/2 web server" homepage "https://caddyserver.com/" url "https://github.com/mholt/caddy/archive/v0.11.5.tar.gz" sha256 "ab2dc210bc7089fa7d041e702663e592b480945aa99f14b348090091103b7ec5" head "https://github.com/mholt/caddy.git" bottle do cellar :any_skip_relocation sha256 "27191a06eab88e00de8e26151d8dad30f64d6b4255d860feaa52db9e332df7be" => :mojave sha256 "815640cfb1d339447b762a8d79feb92c334d31553a894c921e7ed94467c06f47" => :high_sierra sha256 "e9a344ad86a981d5600d8e49f2a48f45c50ce8c964ce7397f3d122ed5d62edb8" => :sierra end depends_on "go" => :build def install ENV["GOPATH"] = buildpath ENV["GOOS"] = "darwin" ENV["GOARCH"] = "amd64" (buildpath/"src/github.com/mholt").mkpath ln_s buildpath, "src/github.com/mholt/caddy" system "go", "build", "-ldflags", "-X github.com/mholt/caddy/caddy/caddymain.gitTag=#{version}", "-o", bin/"caddy", "github.com/mholt/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