122 lines
4.6 KiB
Ruby
122 lines
4.6 KiB
Ruby
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: "v2.3.0",
|
|
revision: "090f681737896feb99870ee534c9ccc4203b9a6d"
|
|
license "MIT"
|
|
head "https://github.com/influxdata/influxdb.git", branch: "master"
|
|
|
|
# The regex below omits a rogue `v9.9.9` tag that breaks version comparison.
|
|
livecheck do
|
|
url :stable
|
|
regex(/^v?((?!9\.9\.9)\d+(?:\.\d+)+)$/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, arm64_monterey: "95105d666775e9a4b652a430222da82f15f7bdf11e02508cce1c7e00f6b25ec7"
|
|
sha256 cellar: :any_skip_relocation, arm64_big_sur: "202bd77fdae7445a217740f9964b07e765cf262a01dea787268ccf4423ed84b3"
|
|
sha256 cellar: :any_skip_relocation, monterey: "cbb3dd12f7730b73e5d59c50462e2c252b2e0a2d3360a884e7fd54f5bca125fc"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "7921499d12ad9c04673d4d57a4a8c0f0399ae765829de04cf7a192e648514769"
|
|
sha256 cellar: :any_skip_relocation, catalina: "48285a09744171ad0ca5b9e95b9e7559388a3deb7c00f5b90febd52d209a25ec"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "b5b6262d944954a1396ef7c87b2e712f7fa26c2f3d0de0de0d578c2d7fc26f70"
|
|
end
|
|
|
|
depends_on "breezy" => :build
|
|
depends_on "go" => :build
|
|
depends_on "pkg-config" => :build
|
|
depends_on "protobuf" => :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 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
|
|
|
|
# NOTE: The version/URL here is specified in scripts/fetch-ui-assets.sh in influxdb.
|
|
# If you're upgrading to a newer influxdb version, check to see if this needs upgraded too.
|
|
resource "ui-assets" do
|
|
url "https://github.com/influxdata/ui/releases/download/OSS-2.1.2/build.tar.gz"
|
|
sha256 "7d78d284d25f28dfd940d407a17f7f3aee1706b5dabc237eadc3bef0031ce548"
|
|
end
|
|
|
|
def install
|
|
# Set up the influxdata pkg-config wrapper to enable just-in-time compilation & linking
|
|
# of the Rust components in the server.
|
|
resource("pkg-config-wrapper").stage do
|
|
system "go", "build", *std_go_args(output: buildpath/"bootstrap/pkg-config")
|
|
end
|
|
ENV.prepend_path "PATH", buildpath/"bootstrap"
|
|
|
|
# Extract pre-build UI resources to the location expected by go-bindata.
|
|
resource("ui-assets").stage(buildpath/"static/data/build")
|
|
# Embed UI files into the Go source code.
|
|
system "make", "generate-web-assets"
|
|
|
|
# Build the server.
|
|
ldflags = %W[
|
|
-s
|
|
-w
|
|
-X main.version=#{version}
|
|
-X main.commit=#{Utils.git_short_head(length: 10)}
|
|
-X main.date=#{time.iso8601}
|
|
]
|
|
|
|
system "go", "build", *std_go_args(output: bin/"influxd", ldflags: ldflags),
|
|
"-tags", "assets,sqlite_foreign_keys,sqlite_json", "./cmd/influxd"
|
|
|
|
data = var/"lib/influxdb2"
|
|
data.mkpath
|
|
|
|
# Generate default config file.
|
|
config = buildpath/"config.yml"
|
|
config.write Utils.safe_popen_read(bin/"influxd", "print-config",
|
|
"--bolt-path=#{data}/influxdb.bolt",
|
|
"--engine-path=#{data}/engine")
|
|
(etc/"influxdb2").install config
|
|
|
|
# Create directory for DB stdout+stderr logs.
|
|
(var/"log/influxdb2").mkpath
|
|
end
|
|
|
|
def caveats
|
|
<<~EOS
|
|
This formula does not contain command-line interface; to install it, run:
|
|
brew install influxdb-cli
|
|
EOS
|
|
end
|
|
|
|
service do
|
|
run bin/"influxd"
|
|
keep_alive true
|
|
working_dir HOMEBREW_PREFIX
|
|
log_path var/"log/influxdb2/influxd_output.log"
|
|
error_log_path var/"log/influxdb2/influxd_output.log"
|
|
environment_variables INFLUXD_CONFIG_PATH: etc/"influxdb2/config.yml"
|
|
end
|
|
|
|
test do
|
|
influxd_port = free_port
|
|
influx_host = "http://localhost:#{influxd_port}"
|
|
ENV["INFLUX_HOST"] = influx_host
|
|
|
|
influxd = fork do
|
|
exec "#{bin}/influxd", "--bolt-path=#{testpath}/influxd.bolt",
|
|
"--engine-path=#{testpath}/engine",
|
|
"--http-bind-address=:#{influxd_port}",
|
|
"--log-level=error"
|
|
end
|
|
sleep 30
|
|
|
|
# Check that the server has properly bundled UI assets and serves them as HTML.
|
|
curl_output = shell_output("curl --silent --head #{influx_host}")
|
|
assert_match "200 OK", curl_output
|
|
assert_match "text/html", curl_output
|
|
ensure
|
|
Process.kill("TERM", influxd)
|
|
Process.wait influxd
|
|
end
|
|
end
|