homebrew-core/Formula/nats-streaming-server.rb
2018-08-24 09:04:25 +02:00

61 lines
2 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.2.tar.gz"
sha256 "7a5683a80bb389060c2da730f1f9f1468bc3a6fd1450c10270a39385908bbca0"
head "https://github.com/nats-io/nats-streaming-server.git"
bottle do
cellar :any_skip_relocation
sha256 "9126e6039277ba8425b5de1593c2d27a328a3c0269d87199ec1cef869abe488c" => :mojave
sha256 "28d4800f7ab48df6f252bf0aa077a8b7bee367a6255a837ded3ebe63358f113a" => :high_sierra
sha256 "e81a7219f394cc618537305fe9a5f70cbabde24c866217d0316146a4a6fa853e" => :sierra
sha256 "c22d5e91787822e384a0fa1b1558592d4e933836ac7ac45cc6e1c13e163ce0b2" => :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