homebrew-core/Formula/gnatsd.rb
2019-02-08 14:21:34 +08:00

61 lines
1.7 KiB
Ruby

class Gnatsd < Formula
desc "Lightweight cloud messaging system"
homepage "https://nats.io"
url "https://github.com/nats-io/gnatsd/archive/v1.4.1.tar.gz"
sha256 "1d319ec9466d5b4d56b8dc0c059bbb50942a8e988c3dcc155271476c3ae629a1"
head "https://github.com/nats-io/gnatsd.git"
bottle do
cellar :any_skip_relocation
sha256 "9da840ed277927cfe8114b55e908a747297714940df6074f6b0368097a866ce1" => :mojave
sha256 "27d0bec653ddcc30784d3da1edd7cad84072387b36f10205b4dced8ac5a47488" => :high_sierra
sha256 "dcb55aeaa2cf3b0a3aa8bd3f31189ad85aebd7f8357f98e90ef82e78b926590d" => :sierra
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
<?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_predicate testpath/"log", :exist?
ensure
Process.kill "SIGINT", pid
Process.wait pid
end
end
end