class Consul < Formula desc "Tool for service discovery, monitoring and configuration" homepage "https://www.consul.io" url "https://github.com/hashicorp/consul.git", :tag => "v0.8.3", :revision => "ea2a82b221c3e0a466a4f38ab4e8718ad8c60621" head "https://github.com/hashicorp/consul.git", :shallow => false bottle do cellar :any_skip_relocation sha256 "81376236b216648d7314e43533dd076a2d2b6af549699270577265e83c2c316f" => :sierra sha256 "db9abd411d005e4df6ad2b4a626d7e316671b2485c055609e8ac02b81d859f81" => :el_capitan sha256 "3465a75f56f5e782033d7e35bb6e6c0dc2aa3e1bb5cf44eaef9d6e37aadaff2f" => :yosemite end option "with-web-ui", "Installs the consul web ui" depends_on "go" => :build resource "web-ui" do url "https://releases.hashicorp.com/consul/0.8.2/consul_0.8.2_web_ui.zip" sha256 "81e6da2e679c0235ef42c6f4054045603e12e51850d979cba9c2d4fe06723131" end def install contents = Dir["{*,.git,.gitignore}"] gopath = buildpath/"gopath" (gopath/"src/github.com/hashicorp/consul").install contents ENV["GOPATH"] = gopath ENV.prepend_create_path "PATH", gopath/"bin" cd gopath/"src/github.com/hashicorp/consul" do system "make" bin.install "bin/consul" zsh_completion.install "contrib/zsh-completion/_consul" end # install web-ui to package share folder. (pkgshare/"web-ui").install resource("web-ui") if build.with? "web-ui" end def caveats; <<-EOS.undent If consul was built with --with-web-ui, you can activate the UI by running consul with `-ui-dir #{pkgshare}/web-ui`. EOS end plist_options :manual => "consul agent -dev -advertise 127.0.0.1" def plist; <<-EOS.undent 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", ".", "-server", "-bootstrap" end sleep 30 system "#{bin}/consul", "info" system "#{bin}/consul", "leave" end end