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.git", :tag => "1.3.3.0", :revision => "d52ab129b7df183bd0141a9c9cd23d2943e9b43d" head "https://github.com/influxdata/chronograf.git" bottle do cellar :any_skip_relocation sha256 "000a37786b5cefeda6efc68779516782e0fe8e25ec935267e004393e918dff1b" => :sierra sha256 "8bb275fd89d6a907c102c7f4b75590de14b2587e3348a42fdb0685a76686d318" => :el_capitan sha256 "3887ac89baa92d3e1b227bfac5a65f993b265b6d8e86d069e23abac4da509c9c" => :yosemite 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" chronograf_path = buildpath/"src/github.com/influxdata/chronograf" chronograf_path.install buildpath.children cd chronograf_path do system "make", "dep" cd "ui" do system "npm", "install", *Language::Node.std_npm_install_args(libexec) system "npm", "run", "build" touch ".jssrc" end system "make", ".bindata" 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