class TraefikAT1 < Formula desc "Modern reverse proxy (v1.7)" homepage "https://traefik.io/" url "https://github.com/containous/traefik/releases/download/v1.7.17/traefik-v1.7.17.src.tar.gz" version "1.7.17" sha256 "e47a984e41aba3b6f9c4950fbf35614a82e1594b4a956465d1ff469bd4b6dd2c" bottle do cellar :any_skip_relocation sha256 "5b639ae42193a3f4e7b69473a61a6b8bf5e945134a4017f4c847b738bb3f7326" => :catalina sha256 "8df14a3386e9413dcbe41a3b77175723c5f522c9f99da59dbbe72f2aa7fe585f" => :mojave sha256 "4b920e2f3a890295177f2a4219226b0eaf339eb2da272b215117f66aa20ecc36" => :high_sierra end keg_only :versioned_formula depends_on "go" => :build depends_on "go-bindata" => :build depends_on "node" => :build depends_on "yarn" => :build def install ENV["GOPATH"] = buildpath (buildpath/"src/github.com/containous/traefik").install buildpath.children cd "src/github.com/containous/traefik" do cd "webui" do system "yarn", "upgrade" system "yarn", "install" system "yarn", "run", "build" end system "go", "generate" system "go", "build", "-o", bin/"traefik", "./cmd/traefik" prefix.install_metafiles end end plist_options :manual => "traefik" def plist <<~EOS KeepAlive Label #{plist_name} ProgramArguments #{opt_bin}/traefik --configfile=#{etc/"traefik/traefik.toml"} EnvironmentVariables RunAtLoad WorkingDirectory #{var} StandardErrorPath #{var}/log/traefik.log StandardOutPath #{var}/log/traefik.log EOS end test do require "socket" web_server = TCPServer.new(0) http_server = TCPServer.new(0) web_port = web_server.addr[1] http_port = http_server.addr[1] web_server.close http_server.close (testpath/"traefik.toml").write <<~EOS [web] address = ":#{web_port}" [entryPoints.http] address = ":#{http_port}" EOS begin pid = fork do exec bin/"traefik", "--configfile=#{testpath}/traefik.toml" end sleep 5 cmd = "curl -sIm3 -XGET http://localhost:#{web_port}/dashboard/" assert_match /200 OK/m, shell_output(cmd) ensure Process.kill("HUP", pid) end end end