homebrew-core/Formula/influxdb@1.rb

90 lines
3.3 KiB
Ruby

class InfluxdbAT1 < Formula
desc "Time series, events, and metrics database"
homepage "https://influxdata.com/time-series-platform/influxdb/"
url "https://github.com/influxdata/influxdb/archive/v1.9.8.tar.gz"
sha256 "c013f167437522475f47772f3506d10bab2a818f38aa4c0005a5b75cf78fd8da"
license "MIT"
livecheck do
url :stable
regex(/^v?(1(?:\.\d+)+)$/i)
end
bottle do
sha256 cellar: :any_skip_relocation, arm64_monterey: "9f4281fdaa92e8ea6d6b10e0e061a1ae457f2d5460225cee1714637f220eaf28"
sha256 cellar: :any_skip_relocation, arm64_big_sur: "7ea5470b2667e7c5f2648e315d930d8fa001a6e2462e170e6e50141bcee38d2b"
sha256 cellar: :any_skip_relocation, monterey: "a1d48a422ec9ee8e30dbc4331fe883518a6e4693256d4099a17554445a226fc3"
sha256 cellar: :any_skip_relocation, big_sur: "7db57d7c9886a06f00e32131b47d10ab8f977ac15d4a7cbdc654a9d18f0ef28d"
sha256 cellar: :any_skip_relocation, catalina: "99b79b20ed49fdbb8caa230b1705db89b300cf9d2214f631fc4b5da71911dd99"
sha256 cellar: :any_skip_relocation, x86_64_linux: "bd4cddd222707f38eb332f4eaa01c8051990d957951991d6ca9fa477c6eca773"
end
keg_only :versioned_formula
depends_on "go" => :build
depends_on "pkg-config" => :build
depends_on "rust" => :build
# NOTE: The version here is specified in the go.mod of influxdb.
# If you're upgrading to a newer influxdb version, check to see if this needs
# to be upgraded too.
resource "pkg-config-wrapper" do
url "https://github.com/influxdata/pkg-config/archive/refs/tags/v0.2.11.tar.gz"
sha256 "52b22c151163dfb051fd44e7d103fc4cde6ae8ff852ffc13adeef19d21c36682"
end
def install
# Set up the influxdata pkg-config wrapper
resource("pkg-config-wrapper").stage do
system "go", "build", *std_go_args(output: buildpath/"bootstrap/pkg-config")
end
ENV.prepend_path "PATH", buildpath/"bootstrap"
ldflags = "-s -w -X main.version=#{version}"
%w[influxd influx influx_tools influx_inspect].each do |f|
system "go", "build", *std_go_args(output: bin/f, ldflags: ldflags), "./cmd/#{f}"
end
etc.install "etc/config.sample.toml" => "influxdb.conf"
inreplace etc/"influxdb.conf" 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
(var/"influxdb/data").mkpath
(var/"influxdb/meta").mkpath
(var/"influxdb/wal").mkpath
end
service do
run [opt_bin/"influxd", "-config", HOMEBREW_PREFIX/"etc/influxdb.conf"]
keep_alive true
working_dir var
log_path var/"log/influxdb.log"
error_log_path var/"log/influxdb.log"
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 6
output = shell_output("curl -Is localhost:8086/ping")
assert_match "X-Influxdb-Version:", output
ensure
Process.kill("SIGTERM", pid)
Process.wait(pid)
end
end
end