61 lines
1.7 KiB
Ruby
61 lines
1.7 KiB
Ruby
class Gnatsd < Formula
|
|
desc "Lightweight cloud messaging system"
|
|
homepage "https://nats.io"
|
|
url "https://github.com/nats-io/gnatsd/archive/v1.4.0.tar.gz"
|
|
sha256 "193778c9c697823d5a198552236fb2f519d509213fbbbea77cd4341719066bfb"
|
|
head "https://github.com/nats-io/gnatsd.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "d02e1ef6f2a79bf5305a56173f3339366a711e2e50ce973a9a25fd70b6e073dc" => :mojave
|
|
sha256 "1a3dacb00e6caa3f828557444eb0f5e2e0c4dac1e833b1c0824e894de35c4f6c" => :high_sierra
|
|
sha256 "01e8ec71e94262c00e30bfd80523caf2fb3b0fe859de05d5bfdd7ba6c0ccbc0a" => :sierra
|
|
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
|