class Caddy < Formula desc "Alternative general-purpose HTTP/2 web server" homepage "https://caddyserver.com/" url "https://github.com/mholt/caddy/archive/v0.11.4.tar.gz" sha256 "5f95c5dc8e0d6a63ae067bdfa42f78a4ca467cfff5407934582f1133ffcda532" head "https://github.com/mholt/caddy.git" bottle do cellar :any_skip_relocation sha256 "97a8a27c5a61d5f183256902e9f9a64e1af3242a95cc45871395da0525500e3c" => :mojave sha256 "6642526ce6bd1937b961a2493ceb617391d053a17ec3ca051c7c17065db80de3" => :high_sierra sha256 "73cad2bde3a3c48e9204d44d4737e61048ea23da2e0cd767578068325b25851c" => :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