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.3.10.0.tar.gz" sha256 "73a82a1a9ae4c3f734f0469f2ccab1066fef526c5574c0d38d67c2afa7889811" head "https://github.com/influxdata/chronograf.git" bottle do cellar :any_skip_relocation sha256 "9b3df894170ce620358e481dd6e4edf2d6607773a1e0d195c18f9cd09479b067" => :high_sierra sha256 "033abefc94be98185b42cf9897c6a66a55e9c0da64da286c56972cc9310eba2b" => :sierra sha256 "e2cded8cee2a1d18529168b2dc6918e2a0cab993b4be0d09ec62be5a486c1669" => :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