110 lines
3.5 KiB
Ruby
110 lines
3.5 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 => "v1.5.2",
|
|
:revision => "02d7d4f043b34ecb4e9b2dbec298c6f9450c2a32"
|
|
head "https://github.com/influxdata/influxdb.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "8861c833c08d0d480a3942e1e8434f1ba93847310373c0ae719e23fc9a47629d" => :high_sierra
|
|
sha256 "e7de0c25b135506ce538398284188c1ddc94aff8a9a2877ccb76b09dad1bcb4b" => :sierra
|
|
sha256 "366c205640a1fb19bfeafdf3dacd739005d43f82c369541046d2049ee17e33d6" => :el_capitan
|
|
end
|
|
|
|
depends_on "gdm" => :build
|
|
depends_on "go" => :build
|
|
|
|
def install
|
|
ENV["GOPATH"] = buildpath
|
|
influxdb_path = buildpath/"src/github.com/influxdata/influxdb"
|
|
influxdb_path.install Dir["*"]
|
|
revision = `git rev-parse HEAD`.strip
|
|
version = `git describe --tags`.strip
|
|
|
|
cd influxdb_path do
|
|
system "gdm", "restore"
|
|
system "go", "install",
|
|
"-ldflags", "-X main.version=#{version} -X main.commit=#{revision} -X main.branch=master",
|
|
"./..."
|
|
end
|
|
|
|
inreplace influxdb_path/"etc/config.sample.toml" 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
|
|
|
|
bin.install "bin/influxd"
|
|
bin.install "bin/influx"
|
|
bin.install "bin/influx_tsm"
|
|
bin.install "bin/influx_stress"
|
|
bin.install "bin/influx_inspect"
|
|
etc.install influxdb_path/"etc/config.sample.toml" => "influxdb.conf"
|
|
|
|
(var/"influxdb/data").mkpath
|
|
(var/"influxdb/meta").mkpath
|
|
(var/"influxdb/wal").mkpath
|
|
end
|
|
|
|
plist_options :manual => "influxd -config #{HOMEBREW_PREFIX}/etc/influxdb.conf"
|
|
|
|
def plist; <<~EOS
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
<plist version="1.0">
|
|
<dict>
|
|
<key>KeepAlive</key>
|
|
<dict>
|
|
<key>SuccessfulExit</key>
|
|
<false/>
|
|
</dict>
|
|
<key>Label</key>
|
|
<string>#{plist_name}</string>
|
|
<key>ProgramArguments</key>
|
|
<array>
|
|
<string>#{opt_bin}/influxd</string>
|
|
<string>-config</string>
|
|
<string>#{HOMEBREW_PREFIX}/etc/influxdb.conf</string>
|
|
</array>
|
|
<key>RunAtLoad</key>
|
|
<true/>
|
|
<key>WorkingDirectory</key>
|
|
<string>#{var}</string>
|
|
<key>StandardErrorPath</key>
|
|
<string>#{var}/log/influxdb.log</string>
|
|
<key>StandardOutPath</key>
|
|
<string>#{var}/log/influxdb.log</string>
|
|
<key>SoftResourceLimits</key>
|
|
<dict>
|
|
<key>NumberOfFiles</key>
|
|
<integer>10240</integer>
|
|
</dict>
|
|
</dict>
|
|
</plist>
|
|
EOS
|
|
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 1
|
|
output = shell_output("curl -Is localhost:8086/ping")
|
|
sleep 1
|
|
assert_match /X-Influxdb-Version:/, output
|
|
ensure
|
|
Process.kill("SIGINT", pid)
|
|
Process.wait(pid)
|
|
end
|
|
end
|
|
end
|