class NatsStreamingServer < Formula desc "Lightweight cloud messaging system" homepage "https://nats.io" url "https://github.com/nats-io/nats-streaming-server/archive/v0.5.0.tar.gz" sha256 "b9d353964b6fa159cafdc304d163a296647e811b2c4ad4570caeb7000138e4cb" head "https://github.com/nats-io/nats-streaming-server.git" bottle do cellar :any_skip_relocation sha256 "48e764cf78c7a2ee45f6eefbb087b7f7d25336985cd86e0e980edb683ab78f40" => :high_sierra sha256 "53632dff52482bfc78bbfdbbbf708058d46c728685af44a2e27b04d4bf0a3a53" => :sierra sha256 "2d42f45471c50ce0f8f6eaad57d643041eb6644744a876c2333a3d4ac8f908ca" => :el_capitan sha256 "805e398fa4517b4996c5f86774fa9282114c7371561dd7d0d7ff24badaafb331" => :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