homebrew-core/Formula/chronograf.rb
2019-08-21 23:38:54 +08:00

87 lines
2.6 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.7.13.tar.gz"
sha256 "3482732de811b3ec8af75eeda07876b6e45c4e1ec030052e1557f6bd427e2965"
head "https://github.com/influxdata/chronograf.git"
bottle do
cellar :any_skip_relocation
sha256 "4c961e4a34d2506643de3c3383926da470f02da42940a1b8ba6dd15701900b3c" => :mojave
sha256 "965b93fe47b88da4367abb32f296d5a80f9fb0d524d060f949b74b3eb7e5b9f1" => :high_sierra
sha256 "b3e0c1f1b32fec7413a6080039284bcf47d1a311c72caec370c216ff5047e032" => :sierra
end
depends_on "go" => :build
depends_on "node" => :build
depends_on "yarn" => :build
depends_on "influxdb"
depends_on "kapacitor"
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
cd "ui" do # fix node 12 compatibility
system "yarn", "upgrade", "parcel@1.11.0", "node-sass@4.12.0"
end
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 3
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