class Gnatsd < Formula desc "Lightweight cloud messaging system" homepage "https://nats.io" url "https://github.com/nats-io/gnatsd/archive/v0.9.2.tar.gz" sha256 "307a9cc8e1cd460865c0c9278ee64120711f3169c9c5bc22e08fadd5884a5201" head "https://github.com/apcera/gnatsd.git" bottle do cellar :any_skip_relocation sha256 "d7409e50dd28d05015ac977444a4725c3d362c1ee9a58ebdc8ef378e19c4f53b" => :el_capitan sha256 "216b24c9e0fcc6982ceafbc050aaf15460988a792917b2147f467d32f4fd1d4d" => :yosemite sha256 "d1d8243cb6268a313a930ee145c093d6b54163b70a5e485fb09dbfee37e592e1" => :mavericks 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/gnatsd" system "go", "build", "-o", bin/"gnatsd", "main.go" end plist_options :manual => "gnatsd" def plist; <<-EOS.undent Label #{plist_name} ProgramArguments #{opt_bin}/gnatsd RunAtLoad EOS end test do pid = fork do exec bin/"gnatsd", "--port=8085", "--pid=#{testpath}/pid", "--log=#{testpath}/log" end sleep 3 begin assert_match version.to_s, shell_output("curl localhost:8085") assert File.exist?(testpath/"log") ensure Process.kill "SIGINT", pid Process.wait pid end end end