homebrew-core/Formula/consul.rb
2017-07-23 03:44:00 -07:00

78 lines
2.2 KiB
Ruby

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.9.0",
:revision => "b79d951ced8c5f18fe73d35b2806f3435e40cd64"
head "https://github.com/hashicorp/consul.git",
:shallow => false
bottle do
cellar :any_skip_relocation
rebuild 1
sha256 "92e66b89cbf87c9a200579ec4a1ecfbacf1a2b314eed7b8e933c56b8228a620b" => :sierra
sha256 "4ff67ad62cdfc3d16086efc6b16b0a2f6e9a85dc82a6724c22050d427a71fb84" => :el_capitan
sha256 "8663f127a5b71e6ad592709d52ffeff68395ebba2b04aafb2c531610d394b707" => :yosemite
end
depends_on "go" => :build
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
end
plist_options :manual => "consul agent -dev -advertise 127.0.0.1"
def plist; <<-EOS.undent
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/consul</string>
<string>agent</string>
<string>-dev</string>
<string>-advertise</string>
<string>127.0.0.1</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{var}</string>
<key>StandardErrorPath</key>
<string>#{var}/log/consul.log</string>
<key>StandardOutPath</key>
<string>#{var}/log/consul.log</string>
</dict>
</plist>
EOS
end
test do
fork do
exec "#{bin}/consul", "agent", "-data-dir", "."
end
sleep 3
system "#{bin}/consul", "leave"
end
end