Skip to content

Commit ed7fe31

Browse files
chenrui333daeho-ro
authored andcommitted
influxdb@2 2.7.12 (new formula)
Signed-off-by: Rui Chen <[email protected]>
1 parent 8173510 commit ed7fe31

File tree

1 file changed

+125
-0
lines changed

1 file changed

+125
-0
lines changed

Formula/i/[email protected]

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
class InfluxdbAT2 < Formula
2+
desc "Time series, events, and metrics database"
3+
homepage "https://influxdata.com/time-series-platform/influxdb/"
4+
url "https://github.com/influxdata/influxdb.git",
5+
tag: "v2.7.12",
6+
revision: "ec9dcde5d6f0e1c4d15ff2332127987a42ca30fc"
7+
license "MIT"
8+
9+
livecheck do
10+
url :stable
11+
regex(/^v?(2(?:\.\d+)+)$/i)
12+
end
13+
14+
keg_only :versioned_formula
15+
16+
depends_on "breezy" => :build
17+
depends_on "go" => :build
18+
depends_on "pkgconf" => :build
19+
depends_on "protobuf" => :build
20+
depends_on "rust" => :build
21+
22+
# NOTE: The version here is specified in the go.mod of influxdb.
23+
# If you're upgrading to a newer influxdb version, check to see if this needs upgraded too.
24+
resource "pkg-config-wrapper" do
25+
url "https://github.com/influxdata/pkg-config/archive/refs/tags/v0.2.14.tar.gz"
26+
sha256 "465d2fb3fc6dab9aca60e3ee3ca623ea346f3544d53082505645f81a7c4cd6d3"
27+
28+
livecheck do
29+
url "https://raw.githubusercontent.com/influxdata/influxdb/v#{LATEST_VERSION}/go.mod"
30+
regex(/pkg-config\s+v?(\d+(?:\.\d+)+)/i)
31+
end
32+
end
33+
34+
# NOTE: The version/URL here is specified in scripts/fetch-ui-assets.sh in influxdb.
35+
# If you're upgrading to a newer influxdb version, check to see if this needs upgraded too.
36+
resource "ui-assets" do
37+
url "https://github.com/influxdata/ui/releases/download/OSS-v2.7.12/build.tar.gz"
38+
sha256 "682f8660c6b160a918f4631a791c76da1437c62de47d6a5a4cb0bd6a3a8e6800"
39+
40+
livecheck do
41+
url "https://raw.githubusercontent.com/influxdata/influxdb/v#{LATEST_VERSION}/scripts/fetch-ui-assets.sh"
42+
regex(/UI_RELEASE=["']?OSS[._-]v?(\d+(?:\.\d+)+)["']?$/i)
43+
end
44+
end
45+
46+
def install
47+
# Set up the influxdata pkg-config wrapper to enable just-in-time compilation & linking
48+
# of the Rust components in the server.
49+
resource("pkg-config-wrapper").stage do
50+
system "go", "build", *std_go_args(output: buildpath/"bootstrap/pkg-config")
51+
end
52+
ENV.prepend_path "PATH", buildpath/"bootstrap"
53+
54+
# Extract pre-build UI resources to the location expected by go-bindata.
55+
resource("ui-assets").stage(buildpath/"static/data/build")
56+
# Embed UI files into the Go source code.
57+
system "make", "generate-web-assets"
58+
59+
# Build the server.
60+
ldflags = %W[
61+
-s -w
62+
-X main.version=#{version}
63+
-X main.commit=#{Utils.git_short_head(length: 10)}
64+
-X main.date=#{time.iso8601}
65+
]
66+
tags = %w[
67+
assets
68+
sqlite_foreign_keys
69+
sqlite_json
70+
]
71+
72+
system "go", "build", *std_go_args(output: bin/"influxd", ldflags:, tags:), "./cmd/influxd"
73+
74+
data = var/"lib/influxdb2"
75+
data.mkpath
76+
77+
# Generate default config file.
78+
config = buildpath/"config.yml"
79+
config.write Utils.safe_popen_read(bin/"influxd", "print-config",
80+
"--bolt-path=#{data}/influxdb.bolt",
81+
"--engine-path=#{data}/engine")
82+
(etc/"influxdb2").install config
83+
84+
# Create directory for DB stdout+stderr logs.
85+
(var/"log/influxdb2").mkpath
86+
end
87+
88+
def caveats
89+
<<~EOS
90+
This formula does not contain command-line interface; to install it, run:
91+
brew install influxdb-cli
92+
EOS
93+
end
94+
95+
service do
96+
run opt_bin/"influxd"
97+
keep_alive true
98+
working_dir HOMEBREW_PREFIX
99+
log_path var/"log/influxdb2/influxd_output.log"
100+
error_log_path var/"log/influxdb2/influxd_output.log"
101+
environment_variables INFLUXD_CONFIG_PATH: etc/"influxdb2/config.yml"
102+
end
103+
104+
test do
105+
influxd_port = free_port
106+
influx_host = "http://localhost:#{influxd_port}"
107+
ENV["INFLUX_HOST"] = influx_host
108+
109+
influxd = fork do
110+
exec "#{bin}/influxd", "--bolt-path=#{testpath}/influxd.bolt",
111+
"--engine-path=#{testpath}/engine",
112+
"--http-bind-address=:#{influxd_port}",
113+
"--log-level=error"
114+
end
115+
sleep 30
116+
117+
# Check that the server has properly bundled UI assets and serves them as HTML.
118+
curl_output = shell_output("curl --silent --head #{influx_host}")
119+
assert_match "200 OK", curl_output
120+
assert_match "text/html", curl_output
121+
ensure
122+
Process.kill("TERM", influxd)
123+
Process.wait influxd
124+
end
125+
end

0 commit comments

Comments
 (0)