homebrew-core/Formula/nomad.rb

78 lines
2.2 KiB
Ruby

class Nomad < Formula
desc "Distributed, Highly Available, Datacenter-Aware Scheduler"
homepage "https://www.nomadproject.io"
url "https://github.com/hashicorp/nomad/archive/v0.12.7.tar.gz"
sha256 "0890978c03e91163f64f0364069a9cb44ebdb1c6087aa23d77eceaf1be5d6fd0"
license "MPL-2.0"
head "https://github.com/hashicorp/nomad.git"
livecheck do
url :head
regex(/^v?(\d+(?:\.\d+)+)$/i)
end
bottle do
cellar :any_skip_relocation
sha256 "ffb1bc5b8a0c39052d3cb8a3e786be2aff0d363a51d781714fbe97683743f0ec" => :catalina
sha256 "a854e36509256fe809b14460b227bc215d1524df02079ca3b390cdc6ed76e0a7" => :mojave
sha256 "c913b2e2fd5b2eed1b04ca2a0c863890c07ee0421a1a1367921833fb242df8a0" => :high_sierra
end
depends_on "go" => :build
def install
ENV["GOPATH"] = buildpath
src = buildpath/"src/github.com/hashicorp/nomad"
src.install buildpath.children
src.cd do
system "go", "build", "-tags", "ui", "-o", bin/"nomad"
prefix.install_metafiles
end
end
plist_options manual: "nomad agent -dev"
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}/nomad</string>
<string>agent</string>
<string>-dev</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{var}</string>
<key>StandardErrorPath</key>
<string>#{var}/log/nomad.log</string>
<key>StandardOutPath</key>
<string>#{var}/log/nomad.log</string>
</dict>
</plist>
EOS
end
test do
pid = fork do
exec "#{bin}/nomad", "agent", "-dev"
end
sleep 10
ENV.append "NOMAD_ADDR", "http://127.0.0.1:4646"
system "#{bin}/nomad", "node-status"
ensure
Process.kill("TERM", pid)
end
end