133 lines
5.1 KiB
Ruby
133 lines
5.1 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.6.0",
|
|
revision: "24a2b621ea74abb498d3864bd27cf38181999c5c"
|
|
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_ventura: "82989993a67307372005dfe342365139ba3186923c091603a285e6ec75dcf60f"
|
|
sha256 cellar: :any_skip_relocation, arm64_monterey: "22f2d4cb94ddea4b014ff9bd380db43fa9477b76f1a485a38d50e8f532755613"
|
|
sha256 cellar: :any_skip_relocation, arm64_big_sur: "e4758da4dd228aa1a0c907e9fe85da889ed07dec5f68fe88f82c293f0ff1b406"
|
|
sha256 cellar: :any_skip_relocation, ventura: "14eff191f86adfe394cddf084d25d57c19b953eb4220be5a84acc05b8c49fabc"
|
|
sha256 cellar: :any_skip_relocation, monterey: "6d3b5e75fac43fddace0062255a79f513397a2b7efc94f3206fd9caca0f65aae"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "212013832a421e77585b619583d45218ed52f0251eeacfecee620d5a659bff47"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "c9c2787ae0874ab93a1156c3266be0b97d5c71c1f269bff5c4e31a0f8fb52bff"
|
|
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"
|
|
|
|
livecheck do
|
|
url "https://raw.githubusercontent.com/influxdata/influxdb/v#{LATEST_VERSION}/go.mod"
|
|
regex(/pkg-config\s+v?(\d+(?:\.\d+)+)/i)
|
|
end
|
|
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-v2.6.0/build.tar.gz"
|
|
sha256 "e3a492886f7d22b88f6c0c852c6ff6dc6993a18b0dbde41dab6f66309072ba85"
|
|
|
|
livecheck do
|
|
url "https://raw.githubusercontent.com/influxdata/influxdb/v#{LATEST_VERSION}/scripts/fetch-ui-assets.sh"
|
|
regex(/UI_RELEASE=["']?OSS[._-]v?(\d+(?:\.\d+)+)["']?$/i)
|
|
end
|
|
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
|