homebrew-core/Formula/gnatsd.rb
2018-08-22 13:10:03 +02:00

62 lines
1.8 KiB
Ruby

class Gnatsd < Formula
desc "Lightweight cloud messaging system"
homepage "https://nats.io"
url "https://github.com/nats-io/gnatsd/archive/v1.2.0.tar.gz"
sha256 "9624ce12adb528e86c03f78305c13f9c5f4edb48cf7b0db123d786f12be00590"
head "https://github.com/nats-io/gnatsd.git"
bottle do
cellar :any_skip_relocation
sha256 "d393647351ecc8888b2b1a862042c75ec2ba6b34232cb5feed381d07b95aec9a" => :mojave
sha256 "90b0d83d6c017b0cc00719737766caf1ddeb561937bf716eb6df8912b311803d" => :high_sierra
sha256 "06fe209745c21694dd9a0b96a8e7135322d944271017f5ddd928f774a9549ec7" => :sierra
sha256 "4c840c3e72fff4fa9a74663e698d3be2c18e33c19639a7fe2e37cd4cbf7cf015" => :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/gnatsd"
system "go", "build", "-o", bin/"gnatsd", "main.go"
end
plist_options :manual => "gnatsd"
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}/gnatsd</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
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_predicate testpath/"log", :exist?
ensure
Process.kill "SIGINT", pid
Process.wait pid
end
end
end