class NatsStreamingServer < Formula desc "Lightweight cloud messaging system" homepage "https://nats.io" url "https://github.com/nats-io/nats-streaming-server/archive/v0.3.0.tar.gz" sha256 "22f062d012841f7d5e45b10c21ebe59b6a12299a4b42e6a478f2ad5f3144386b" head "https://github.com/nats-io/nats-streaming-server.git" bottle do cellar :any_skip_relocation sha256 "2956fe40f3672c59e671e551ebc77cf6a14b166c16bf4a0964f6459aaeb49352" => :sierra sha256 "350d76170f8391b7c495b98477d5cecbde12b7cdb08b58592fdf8644cbe6fc0f" => :el_capitan sha256 "4c03dc1cf352b47c40a9f9c6b2d0e883e22f0a56c6b3f1bc81c308e9734d5f46" => :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