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.4", :revision => "f4360770d8e7b852e2d05835b583d20799e58133" head "https://github.com/hashicorp/consul.git", :shallow => false bottle do cellar :any_skip_relocation sha256 "39eb37b0201fea5f5b08ebf503886873907bda308da0941e83d80aefcc93220b" => :sierra sha256 "4fd6bc7c9449ebc555710f5c167e8d7bfa6d4e9054ec57938f7c484310ddc91f" => :el_capitan sha256 "f93e4db2ee0798311adeaf76075f31183269a8be398440f90fe70a6c8e26254e" => :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.4/consul_0.8.4_web_ui.zip" sha256 "7a49924a872205002b2bf72af8c82d5560d4a7f4a58b2f65ee284dd254ebd063" 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