homebrew-core/Formula/chronograf.rb

85 lines
2.5 KiB
Ruby

require "language/node"
class Chronograf < Formula
desc "Open source monitoring and visualization UI for the TICK stack"
homepage "https://docs.influxdata.com/chronograf/latest/"
url "https://github.com/influxdata/chronograf/archive/1.4.0.1.tar.gz"
sha256 "31df9f36354d07d0d935ae095b74fab003d5aced658763b8eb4bfd2a51c22bdc"
head "https://github.com/influxdata/chronograf.git"
bottle do
cellar :any_skip_relocation
sha256 "6002c9963f30a79754076dda58ef4aeb9a7d6e7ba157a5398f9474c68a1a1356" => :high_sierra
sha256 "fcbf8c991b12b44cecb049e2e3031a78ee695f3733ff82632b53c7d3dff2a0c6" => :sierra
sha256 "b94673f2fa103f1f49ba31479d3357019dbe281a3829bda5040a09097f77726d" => :el_capitan
end
depends_on "go" => :build
depends_on "node" => :build
depends_on "yarn" => :build
depends_on "influxdb" => :recommended
depends_on "kapacitor" => :recommended
def install
ENV["GOPATH"] = buildpath
ENV.prepend_create_path "PATH", buildpath/"bin"
Language::Node.setup_npm_environment
chronograf_path = buildpath/"src/github.com/influxdata/chronograf"
chronograf_path.install buildpath.children
cd chronograf_path do
system "make", "dep"
system "make", ".jssrc"
system "make", "chronograf"
bin.install "chronograf"
prefix.install_metafiles
end
end
plist_options :manual => "chronograf"
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>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/chronograf</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{var}</string>
<key>StandardErrorPath</key>
<string>#{var}/log/chronograf.log</string>
<key>StandardOutPath</key>
<string>#{var}/log/chronograf.log</string>
</dict>
</plist>
EOS
end
test do
begin
pid = fork do
exec "#{bin}/chronograf"
end
sleep 1
output = shell_output("curl -s 0.0.0.0:8888/chronograf/v1/")
sleep 1
assert_match %r{/chronograf/v1/layouts}, output
ensure
Process.kill("SIGINT", pid)
Process.wait(pid)
end
end
end