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.2.3.tar.gz" sha256 "1e241eba7557c6f61c599c060a3286ddd661e6ddd1abeeeb88b45d8bedca70e4" head "https://github.com/influxdata/chronograf.git" bottle do cellar :any_skip_relocation sha256 "9f6cc67956ab00edc975c5bad1cdb88aeeda74bdd986e3c5498309d2d9abc7ac" => :high_sierra sha256 "60b4d87c2fd5b70935b9900a9ed1d65a6d5f379da8a45dd822a28f91264f1b45" => :sierra sha256 "90dfc7d99381ea850bb0c56eb02f1000bd4f4b9fa7304540c7088c6b3ff18280" => :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 KeepAlive SuccessfulExit Label #{plist_name} ProgramArguments #{opt_bin}/chronograf RunAtLoad WorkingDirectory #{var} StandardErrorPath #{var}/log/chronograf.log StandardOutPath #{var}/log/chronograf.log 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