homebrew-core/Formula/consul.rb
2018-09-15 09:46:28 +10:00

82 lines
2.4 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.2.3",
:revision => "48d287ef690ada66634885640f3444dbf7b71d18"
head "https://github.com/hashicorp/consul.git",
:shallow => false
bottle do
cellar :any_skip_relocation
sha256 "938e2261902a0e3bbb0cf9b6e8842a6003ad088086ad42b961eb3efef99a19ca" => :mojave
sha256 "cc518fe0780114be32089f7a0de9263304f55230716ae42ee3b8fed002a8a726" => :high_sierra
sha256 "8c2ecf7aa534d40e5e6b5ab9214bfaadcb289499cd87d042e3bbe7ff9dfcad0b" => :sierra
sha256 "09dcde70cd4f255d4f4952e4b294a2c53a8331d83841487d5ef441d707f054e8" => :el_capitan
end
depends_on "go" => :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"] = MacOS.prefer_64_bit? ? "amd64" : "386"
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