100 lines
3.2 KiB
Ruby
100 lines
3.2 KiB
Ruby
class Kapacitor < Formula
|
|
desc "Open source time series data processor"
|
|
homepage "https://github.com/influxdata/kapacitor"
|
|
url "https://github.com/influxdata/kapacitor.git",
|
|
:tag => "v1.0.2",
|
|
:revision => "1011dba109bf3d83366c87873ec285c7f9140d34"
|
|
|
|
head "https://github.com/influxdata/kapacitor.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "d0ca4ea9e07710b79a14e7774c4e28b7e87454e8706300efa29e849efd7d37a7" => :sierra
|
|
sha256 "8ae18cde494e7b5b649b4205e8420541cb77bffceedf6e91282e82de41c156b4" => :el_capitan
|
|
sha256 "fa142b4cf87af4efe8c3be62b999158c0135bc08c20cc45bba528e1333af4c43" => :yosemite
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
|
|
def install
|
|
ENV["GOPATH"] = buildpath
|
|
kapacitor_path = buildpath/"src/github.com/influxdata/kapacitor"
|
|
kapacitor_path.install Dir["*"]
|
|
revision = `git rev-parse HEAD`.strip
|
|
version = `git describe --tags`.strip
|
|
|
|
cd kapacitor_path do
|
|
system "go", "install",
|
|
"-ldflags", "-X main.version=#{version} -X main.commit=#{revision}",
|
|
"./cmd/..."
|
|
end
|
|
|
|
inreplace kapacitor_path/"etc/kapacitor/kapacitor.conf" do |s|
|
|
s.gsub! "/var/lib/kapacitor", "#{var}/kapacitor"
|
|
s.gsub! "/var/log/kapacitor", "#{var}/log"
|
|
end
|
|
|
|
bin.install "bin/kapacitord"
|
|
bin.install "bin/kapacitor"
|
|
etc.install kapacitor_path/"etc/kapacitor/kapacitor.conf" => "kapacitor.conf"
|
|
|
|
(var/"kapacitor/replay").mkpath
|
|
(var/"kapacitor/tasks").mkpath
|
|
end
|
|
|
|
plist_options :manual => "kapacitord -config #{HOMEBREW_PREFIX}/etc/kapacitor.conf"
|
|
|
|
def plist; <<-EOS.undent
|
|
<?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}/kapacitord</string>
|
|
<string>-config</string>
|
|
<string>#{HOMEBREW_PREFIX}/etc/kapacitor.conf</string>
|
|
</array>
|
|
<key>RunAtLoad</key>
|
|
<true/>
|
|
<key>WorkingDirectory</key>
|
|
<string>#{var}</string>
|
|
<key>StandardErrorPath</key>
|
|
<string>#{var}/log/kapacitor.log</string>
|
|
<key>StandardOutPath</key>
|
|
<string>#{var}/log/kapacitor.log</string>
|
|
</dict>
|
|
</plist>
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
(testpath/"config.toml").write shell_output("kapacitord config")
|
|
|
|
inreplace testpath/"config.toml" do |s|
|
|
s.gsub! /disable-subscriptions = false/, "disable-subscriptions = true"
|
|
s.gsub! %r{data_dir = "/.*/.kapacitor"}, "data_dir = \"#{testpath}/kapacitor\""
|
|
s.gsub! %r{/.*/.kapacitor/replay}, "#{testpath}/kapacitor/replay"
|
|
s.gsub! %r{/.*/.kapacitor/tasks}, "#{testpath}/kapacitor/tasks"
|
|
s.gsub! %r{/.*/.kapacitor/kapacitor.db}, "#{testpath}/kapacitor/kapacitor.db"
|
|
end
|
|
|
|
begin
|
|
pid = fork do
|
|
exec "#{bin}/kapacitord -config #{testpath}/config.toml"
|
|
end
|
|
sleep 2
|
|
shell_output("#{bin}/kapacitor list tasks")
|
|
ensure
|
|
Process.kill("SIGINT", pid)
|
|
Process.wait(pid)
|
|
end
|
|
end
|
|
end
|