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

58 lines
1.7 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.17.0.tar.gz"
sha256 "6db2233ebf2788d08134170f30310ce5c330056b6cbc75dde7821b9d1d34c74f"
head "https://github.com/nats-io/nats-streaming-server.git"
bottle do
cellar :any_skip_relocation
sha256 "4abdd8d63284e14e2516b42826c77d70d457b2e9fb67b445fa61295b089e5129" => :catalina
sha256 "7171c6e08bb7a23e535fcc6a97eb201ff2468098bcd8734fa63d48043d2fb0b3" => :mojave
sha256 "d7f7af1bcb54bee3c7d3b530aa3cb86498a1ff54f04d2599d362bb9969c45c96" => :high_sierra
end
depends_on "go" => :build
def install
system "go", "build", "-ldflags", "-s -w", "-trimpath", "-o", bin/"nats-streaming-server"
prefix.install_metafiles
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