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.8.3.tar.gz" sha256 "afc803e3e92e1d7d82d16f5f0a29db82c45e046cbada8fba9ca9ea3b7e9e90ca" head "https://github.com/influxdata/chronograf.git" bottle do cellar :any_skip_relocation sha256 "2defff6a948be00cbb71df717ed3e3a2d782bc2ab0aaa38ced0f421920cc9296" => :high_sierra sha256 "abf4261ae5c4fb2d36e8dfbf44653a06d0cad2cae2c9b9968be70aac9b0ae228" => :sierra sha256 "5311cf3374a33cb524dbe407894a6fb548d0938c00f99fb67ce6381395f7df0c" => :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" end end plist_options :manual => "chronograf" def plist; <<-EOS.undent 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