class NatsStreamingServer < Formula desc "Lightweight cloud messaging system" homepage "https://nats.io" url "https://github.com/nats-io/nats-streaming-server/archive/v0.3.8.tar.gz" sha256 "3106fc9f6f14bf896c8ca216ea85edbb232ddbd4ebfb8f3a276520f26000a9f5" head "https://github.com/nats-io/nats-streaming-server.git" bottle do sha256 "2fc80380e9368b1c7f4261b53515bddbea762f55d28d8a443e08b612b77a787e" => :sierra sha256 "6669019510920f160a13dec8a471a49106e033283537f8d1f5a4adb52b637324" => :el_capitan sha256 "9b2bc452b1607a55a577952ab836514e7d96e76db1fe095f4efeb4450ae43c90" => :yosemite 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.undent Label #{plist_name} ProgramArguments #{opt_bin}/nats-streaming-server RunAtLoad 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 File.exist?(testpath/"log") assert_match version.to_s, File.read(testpath/"log") ensure Process.kill "SIGINT", pid Process.wait pid end end end