class Influxdb < Formula desc "Time series, events, and metrics database" homepage "https://influxdata.com/time-series-platform/influxdb/" url "https://github.com/influxdata/influxdb.git", :tag => "v1.7.7", :revision => "f8fdf652f348fc9980997fe1c972e2b79ddd13b0" head "https://github.com/influxdata/influxdb.git" bottle do cellar :any_skip_relocation sha256 "bc6e598a410fb5c901d3dbc19cf257adaab3c3b0a81924eb56f331de9014bd0e" => :catalina sha256 "aa1cf675fa005f5f5dff6879ca4f5a31886f6d82828037c285656df9786f59c1" => :mojave sha256 "717495212665f27c401ef47bed1c5b0aef13c66155cf1294c03ffbb74b13cd9f" => :high_sierra sha256 "b1efff109de67cb0ee5ff38f6736a7197ac3c1139d856d5b467195508ec82d56" => :sierra end depends_on "dep" => :build depends_on "go" => :build def install ENV["GOPATH"] = buildpath influxdb_path = buildpath/"src/github.com/influxdata/influxdb" influxdb_path.install Dir["*"] revision = `git rev-parse HEAD`.strip version = `git describe --tags`.strip cd influxdb_path do system "dep", "ensure", "-vendor-only" system "go", "install", "-ldflags", "-X main.version=#{version} -X main.commit=#{revision} -X main.branch=master", "./..." end inreplace influxdb_path/"etc/config.sample.toml" do |s| s.gsub! "/var/lib/influxdb/data", "#{var}/influxdb/data" s.gsub! "/var/lib/influxdb/meta", "#{var}/influxdb/meta" s.gsub! "/var/lib/influxdb/wal", "#{var}/influxdb/wal" end bin.install "bin/influxd" bin.install "bin/influx" bin.install "bin/influx_tsm" bin.install "bin/influx_stress" bin.install "bin/influx_inspect" etc.install influxdb_path/"etc/config.sample.toml" => "influxdb.conf" (var/"influxdb/data").mkpath (var/"influxdb/meta").mkpath (var/"influxdb/wal").mkpath end plist_options :manual => "influxd -config #{HOMEBREW_PREFIX}/etc/influxdb.conf" def plist; <<~EOS KeepAlive SuccessfulExit Label #{plist_name} ProgramArguments #{opt_bin}/influxd -config #{HOMEBREW_PREFIX}/etc/influxdb.conf RunAtLoad WorkingDirectory #{var} StandardErrorPath #{var}/log/influxdb.log StandardOutPath #{var}/log/influxdb.log SoftResourceLimits NumberOfFiles 10240 EOS end test do (testpath/"config.toml").write shell_output("#{bin}/influxd config") inreplace testpath/"config.toml" do |s| s.gsub! %r{/.*/.influxdb/data}, "#{testpath}/influxdb/data" s.gsub! %r{/.*/.influxdb/meta}, "#{testpath}/influxdb/meta" s.gsub! %r{/.*/.influxdb/wal}, "#{testpath}/influxdb/wal" end begin pid = fork do exec "#{bin}/influxd -config #{testpath}/config.toml" end sleep 1 output = shell_output("curl -Is localhost:8086/ping") sleep 1 assert_match /X-Influxdb-Version:/, output ensure Process.kill("SIGINT", pid) Process.wait(pid) end end end