homebrew-core/Formula/nats-streaming-server.rb

61 lines
1.9 KiB
Ruby

class NatsStreamingServer < Formula
desc "Lightweight cloud messaging system"
homepage "https://nats.io"
url "https://github.com/nats-io/nats-streaming-server/archive/v0.10.0.tar.gz"
sha256 "8b1d079ae2a30e348bb486a8e697493565170cc3bf2e6cfbe9dd2b1c89176c59"
head "https://github.com/nats-io/nats-streaming-server.git"
bottle do
cellar :any_skip_relocation
sha256 "d312f8120cfde426f9a83b49196373975d6f3ab69a447ae48047572b7fa34baf" => :high_sierra
sha256 "2862b70ee332e4a6bfac0fc3b975069ec412ed96ef0a112b94f01bd5db7fb07b" => :sierra
sha256 "091e4caaecb7023fc8889d58d2fdf043e69cc1c9e7297f11545fa7763541b2b0" => :el_capitan
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/nats-streaming-server"
buildfile = buildpath/"src/github.com/nats-io/nats-streaming-server/nats-streaming-server.go"
system "go", "build", "-v", "-o", bin/"nats-streaming-server", buildfile
end
plist_options :manual => "nats-streaming-server"
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}/nats-streaming-server</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOS
end
test do
pid = fork do
exec "#{bin}/nats-streaming-server --port=8085 --pid=#{testpath}/pid --log=#{testpath}/log"
end
sleep 3
begin
assert_match "INFO", shell_output("curl localhost:8085")
assert_predicate testpath/"log", :exist?
assert_match version.to_s, File.read(testpath/"log")
ensure
Process.kill "SIGINT", pid
Process.wait pid
end
end
end