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.3.5", :revision => "9d9001036d3585cf21925c13a57881bc6c8dcc7e" head "https://github.com/influxdata/influxdb.git" bottle do cellar :any_skip_relocation sha256 "d14f5ff185b38647ef2f56934653ef0bb4011659b7529c6ad58142dd31f71d16" => :high_sierra sha256 "514657b4d83c30cda80be7e3cab8dca010e5d1d52a36e83dfe4196d6ae0e0ef4" => :sierra sha256 "15df876f17bf0212d0bd03355ce7eca8064a3fd4fde7f768b77b1afca3c8dd1f" => :el_capitan sha256 "93995718e66f9dc4c32b652b2805eaf8358da6fc5a648e8a5adcb909828ee7b8" => :yosemite end depends_on "gdm" => :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 "gdm", "restore" 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.undent 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