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.5.0.0.tar.gz" sha256 "501f31e65b84804b478e4e0da470f5723dcd54835df4d85408347da13a7ed4b0" head "https://github.com/influxdata/chronograf.git" bottle do cellar :any_skip_relocation sha256 "aab05a26fee3a19e26ceb5b0d91115d824473666528a8bedf3a47c0b30132662" => :high_sierra sha256 "c75244680946f94ec4d0f533b41eb1d132e8bcc305dc04d6f8cdd5c7f01961d0" => :sierra sha256 "4dfc3f6f5d6e61fb1a665fb66fc4b313df5bf2a029b99002cdb0cc7b87c95444" => :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 # fixes yarn + upath@1.0.4 incompatibility, remove once upath is upgraded to 1.0.5+ Pathname.new("#{ENV["HOME"]}/.yarnrc").write("ignore-engines true\n") 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