63 lines
1.8 KiB
Ruby
63 lines
1.8 KiB
Ruby
class NatsServer < Formula
|
|
desc "Lightweight cloud messaging system"
|
|
homepage "https://nats.io"
|
|
url "https://github.com/nats-io/nats-server/archive/v2.1.2.tar.gz"
|
|
sha256 "2fdbda70191ba02f3e065b0d2d503236865c60e88fa4a7c7e0eae691e7e32b2d"
|
|
head "https://github.com/nats-io/nats-server.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "4edb45f19824f760294780d6b365916ee23c514acfc183d3fe9d52fbb4a189a9" => :catalina
|
|
sha256 "aa5771424fa936d191a62e0e7cdd4c3aa2bfe2ac6cd3869419015ae3808bd426" => :mojave
|
|
sha256 "48c033283b086a6540f0d26b4e0782de589b1b1e481968bdc6f96b86b3549f19" => :high_sierra
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
|
|
def install
|
|
ENV["GOPATH"] = buildpath
|
|
ENV["GO111MODULE"] = "off"
|
|
mkdir_p "src/github.com/nats-io"
|
|
ln_s buildpath, "src/github.com/nats-io/nats-server"
|
|
buildfile = buildpath/"src/github.com/nats-io/nats-server/main.go"
|
|
system "go", "build", "-v", "-o", bin/"nats-server", buildfile
|
|
end
|
|
|
|
plist_options :manual => "nats-server"
|
|
|
|
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}/nats-server</string>
|
|
</array>
|
|
<key>RunAtLoad</key>
|
|
<true/>
|
|
</dict>
|
|
</plist>
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
pid = fork do
|
|
exec bin/"nats-server",
|
|
"--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
|