homebrew-core/Formula/consul.rb
2019-11-27 15:18:42 -05:00

81 lines
2.3 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 => "v1.6.2",
:revision => "1200f25eabc75368484a78698e75f1e61b6ed010"
head "https://github.com/hashicorp/consul.git",
:shallow => false
bottle do
cellar :any_skip_relocation
sha256 "32643f0e02d5a1671be58ecc6038214ffbd60742cdcc70b83a6a72c9f419898b" => :catalina
sha256 "ffc918f234d61990e4762992d8e337e73d839a64e4c43f9e2fc8bb1d512aca3e" => :mojave
sha256 "c9c3305b87e39ffd0b4ae5a31a8b3fd6e811aa3a1314b93a252390ce3edd0bba" => :high_sierra
end
depends_on "go@1.12" => :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"] = "amd64"
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
<?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