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.7.2", :revision => "a9afa0c27f484dd19fe59a80444e64e5352c4408" head "https://github.com/hashicorp/consul.git", :shallow => false bottle do sha256 "c4bd264feef94dc71bf09760d8350b4664a3cc2c625a4c425de00b88df9c9994" => :sierra sha256 "0e9b2941114c706b91a39cffbb9b02d240ef784251f079dab3c43d89c632a268" => :el_capitan sha256 "34b53377cd971b6af9dbffdcbc51f1816dfb9277bc1b5c2eeceef1570bb821ae" => :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.7.2/consul_0.7.2_web_ui.zip" sha256 "c9d2a6e1d1bb6243e5fd23338d92f5c71cdf0a4077f7fcc95fd81800fa1f42a9" 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", "." end sleep 3 system "#{bin}/consul", "leave" end end