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.6.tar.gz"
sha256 "2ec001a9194995d6b2655b057ef5bb53345bf363e61627f563ae99ce8f91e142"
license "MIT"
livecheck do
url :stable
regex(/^v?(1(?:\.\d+)+)$/i)
end
bottle do
sha256 cellar: :any_skip_relocation, arm64_monterey: "42ff02a71e13fb6f034443e9b2dec826a6e68383842550d29bef9b9145069168"
sha256 cellar: :any_skip_relocation, arm64_big_sur: "96fac877490d95a2a18cfe514181b82080bd034b2ab0556f3f46888b96927fc7"
sha256 cellar: :any_skip_relocation, monterey: "9fa799ca468f9f586087e56e359d838dfe68bd8a8fbc63ae6bb9e05b550c7827"
sha256 cellar: :any_skip_relocation, big_sur: "5a84f9b870077815570927b4b3360ad2e2bbd369ac820b91ddd78e6a5531c270"
sha256 cellar: :any_skip_relocation, catalina: "e4e1b20c01729b5db4cfdd88c8d98d417494d77065920df32e680061ae7a7137"
sha256 cellar: :any_skip_relocation, x86_64_linux: "a78d03dbb9de72417dfb446df0e6999a3062e88ac193a3bfd052a868a03b52d0"
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.9.tar.gz"
sha256 "25843e58a3e6994bdafffbc0ef0844978a3d1f999915d6770cb73505fcf87e44"
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