class Traefik < Formula desc "Modern reverse proxy" homepage "https://traefik.io/" url "https://github.com/traefik/traefik/releases/download/v2.4.6/traefik-v2.4.6.src.tar.gz" sha256 "6ef50405cc81ee30813ff0af7dd490b70fbbc300962dc04fcee5a03554f02b1b" license "MIT" head "https://github.com/traefik/traefik.git" bottle do sha256 cellar: :any_skip_relocation, arm64_big_sur: "ac377bc42b83d228db2f688352e99179f63b193c9c99e9579b3d46153605c55e" sha256 cellar: :any_skip_relocation, big_sur: "dd78a91d8e4753f492a19bb2ffdec5b5a4549a9f1ced4d0c1e5ab1e891c71c3b" sha256 cellar: :any_skip_relocation, catalina: "ecd26b01877efc9abec1adb3d8f25b90c5b6a03639744685118245682a921a5c" sha256 cellar: :any_skip_relocation, mojave: "a9a910fca41aed2f8650db2811e7e8ce8b0e7731dfd3d8ff5412cc566479a980" end depends_on "go" => :build depends_on "go-bindata" => :build def install system "go", "generate" system "go", "build", "-ldflags", "-s -w -X github.com/traefik/traefik/v#{version.major}/pkg/version.Version=#{version}", "-trimpath", "-o", bin/"traefik", "./cmd/traefik" 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 ui_port = free_port http_port = free_port (testpath/"traefik.toml").write <<~EOS [entryPoints] [entryPoints.http] address = ":#{http_port}" [entryPoints.traefik] address = ":#{ui_port}" [api] insecure = true dashboard = true EOS begin pid = fork do exec bin/"traefik", "--configfile=#{testpath}/traefik.toml" end sleep 5 cmd_ui = "curl -sIm3 -XGET http://127.0.0.1:#{http_port}/" assert_match "404 Not Found", shell_output(cmd_ui) sleep 1 cmd_ui = "curl -sIm3 -XGET http://127.0.0.1:#{ui_port}/dashboard/" assert_match "200 OK", shell_output(cmd_ui) ensure Process.kill(9, pid) Process.wait(pid) end assert_match version.to_s, shell_output("#{bin}/traefik version 2>&1") end end