class Consul < Formula desc "Tool for service discovery, monitoring and configuration" homepage "https://www.consul.io" url "https://github.com/hashicorp/consul.git", :tag => "v1.0.6", :revision => "9a494b5fb9c86180a5702e29c485df1507a47198" head "https://github.com/hashicorp/consul.git", :shallow => false bottle do cellar :any_skip_relocation rebuild 1 sha256 "426227ee114e91f2560c141722d7b31a148b507a7617485ff1482f8b30f386c3" => :high_sierra sha256 "3154593fd96aa3efd6f2f0c9ca2aa8d1e13685e106a8cebdb5ea55a14e46662c" => :sierra sha256 "aa9f709a5d4a1042584b2f332848e30a62f3e909123fdbfdc6feac033d230ef0" => :el_capitan end depends_on "go" => :build depends_on "gox" => :build def install # Avoid running `go get` inreplace "GNUmakefile", "go get -u -v $(GOTOOLS)", "" ENV["XC_OS"] = "darwin" ENV["XC_ARCH"] = MacOS.prefer_64_bit? ? "amd64" : "386" ENV["GOPATH"] = buildpath contents = Dir["{*,.git,.gitignore}"] (buildpath/"src/github.com/hashicorp/consul").install contents (buildpath/"bin").mkpath cd "src/github.com/hashicorp/consul" do system "make" bin.install "bin/consul" prefix.install_metafiles end end plist_options :manual => "consul agent -dev -advertise 127.0.0.1" def plist; <<~EOS KeepAlive SuccessfulExit Label #{plist_name} ProgramArguments #{opt_bin}/consul agent -dev -advertise 127.0.0.1 RunAtLoad WorkingDirectory #{var} StandardErrorPath #{var}/log/consul.log StandardOutPath #{var}/log/consul.log EOS end test do fork do exec "#{bin}/consul", "agent", "-data-dir", "." end sleep 3 system "#{bin}/consul", "leave" end end