homebrew-core/Formula/nats-streaming-server.rb
2018-03-16 15:19:50 -07:00

60 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.9.0.tar.gz"
sha256 "468beb844c4883dee1b69e8b9186dccb033ec419af40598f00e6a5f46ecb67aa"
head "https://github.com/nats-io/nats-streaming-server.git"
bottle do
cellar :any_skip_relocation
sha256 "f256ff2b9628d6ab0eb5806021da67946ffcb7a59b4285b78bdc48b257beec6e" => :high_sierra
sha256 "669af50135610556d64e201c60feb3c12ca0b7a05e996e0c84aec665f838091c" => :sierra
sha256 "d164fafe66d70255503812c3b5836adbd325c5001dbb21400d0f01e047f87c10" => :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