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.4.1.tar.gz" sha256 "b08bbd7224c9e5c2c74101ec4d0f7952bdade531766aacbfbb21e1dca9b6c3d6" head "https://github.com/influxdata/chronograf.git" bottle do cellar :any_skip_relocation sha256 "655feb017004a28c8bbd18052baf57ea16b842ff9540aafb8b982b59a572f19a" => :high_sierra sha256 "ba14166606f0939d4e7e698485da0fb17b7f959e8c1aded4f14e9cbf899934c1" => :sierra sha256 "19013ed77e9a26dad8c7a0039f71e37f0e528c6ce5d9d0b375fa560924d8d47d" => :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