homebrew-core/Formula/gnatsd.rb
2016-09-25 13:25:40 -04:00

62 lines
1.8 KiB
Ruby

class Gnatsd < Formula
desc "Lightweight cloud messaging system"
homepage "https://nats.io"
url "https://github.com/nats-io/gnatsd/archive/v0.9.4.tar.gz"
sha256 "6465161c52e3e703f88cfe37182904d956234c4346f9ad6eb74903eff0190c98"
head "https://github.com/apcera/gnatsd.git"
bottle do
cellar :any_skip_relocation
sha256 "d660de2ec4e884e748925c1c8343d26d357131826d88cccf55a1dbc83869153c" => :sierra
sha256 "447407dcc51b0536b901a4b9aa006aba4b89de3b077b8fcc015a6b14b80f2838" => :el_capitan
sha256 "0e54745a3e0cf9f33eb62b339a6ab701ee09e6b108427a5c3f8bab38ee011def" => :yosemite
sha256 "78654a5731e84f66ccfa45a85ad241dbca8dd1010e80e856b8cf883ab3ba5b51" => :mavericks
end
depends_on "go" => :build
def install
ENV["GOPATH"] = buildpath
mkdir_p "src/github.com/nats-io"
ln_s buildpath, "src/github.com/nats-io/gnatsd"
system "go", "build", "-o", bin/"gnatsd", "main.go"
end
plist_options :manual => "gnatsd"
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>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/gnatsd</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOS
end
test do
pid = fork do
exec bin/"gnatsd",
"--port=8085",
"--pid=#{testpath}/pid",
"--log=#{testpath}/log"
end
sleep 3
begin
assert_match version.to_s, shell_output("curl localhost:8085")
assert File.exist?(testpath/"log")
ensure
Process.kill "SIGINT", pid
Process.wait pid
end
end
end