82 lines
2.5 KiB
Ruby
82 lines
2.5 KiB
Ruby
class Heartbeat < Formula
|
|
desc "Lightweight Shipper for Uptime Monitoring"
|
|
homepage "https://www.elastic.co/beats/heartbeat"
|
|
url "https://github.com/elastic/beats.git",
|
|
tag: "v7.14.1",
|
|
revision: "703d589a09cfdbfd7f84c1d990b50b6b7f62ac29"
|
|
license "Apache-2.0"
|
|
head "https://github.com/elastic/beats.git"
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, arm64_big_sur: "641e7059af35f1c202f773e1dd3c324daf413a858e287f22edc696214f6ffa1e"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "0d847254f75e8cd096c1a3ce68e63aa0ba23d9af5d7208e622fcd4b8057c4239"
|
|
sha256 cellar: :any_skip_relocation, catalina: "50d89f3858e6a1422bf2aa8d2e059063240901dda66176c3483dc21b29f0172d"
|
|
sha256 cellar: :any_skip_relocation, mojave: "7bdd01eeb8523e60c5ea2925fc216c9f7668203b4ef28e4c1fb783b371f3113e"
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
depends_on "mage" => :build
|
|
depends_on "python@3.9" => :build
|
|
|
|
def install
|
|
# remove non open source files
|
|
rm_rf "x-pack"
|
|
|
|
cd "heartbeat" do
|
|
# prevent downloading binary wheels during python setup
|
|
system "make", "PIP_INSTALL_PARAMS=--no-binary :all", "python-env"
|
|
system "mage", "-v", "build"
|
|
ENV.deparallelize
|
|
system "mage", "-v", "update"
|
|
|
|
(etc/"heartbeat").install Dir["heartbeat.*", "fields.yml"]
|
|
(libexec/"bin").install "heartbeat"
|
|
end
|
|
|
|
(bin/"heartbeat").write <<~EOS
|
|
#!/bin/sh
|
|
exec #{libexec}/bin/heartbeat \
|
|
--path.config #{etc}/heartbeat \
|
|
--path.data #{var}/lib/heartbeat \
|
|
--path.home #{prefix} \
|
|
--path.logs #{var}/log/heartbeat \
|
|
"$@"
|
|
EOS
|
|
end
|
|
|
|
def post_install
|
|
(var/"lib/heartbeat").mkpath
|
|
(var/"log/heartbeat").mkpath
|
|
end
|
|
|
|
service do
|
|
run opt_bin/"heartbeat"
|
|
end
|
|
|
|
test do
|
|
port = free_port
|
|
|
|
(testpath/"config/heartbeat.yml").write <<~EOS
|
|
heartbeat.monitors:
|
|
- type: tcp
|
|
schedule: '@every 5s'
|
|
hosts: ["localhost:#{port}"]
|
|
check.send: "hello\\n"
|
|
check.receive: "goodbye\\n"
|
|
output.file:
|
|
path: "#{testpath}/heartbeat"
|
|
filename: heartbeat
|
|
codec.format:
|
|
string: '%{[monitor]}'
|
|
EOS
|
|
fork do
|
|
exec bin/"heartbeat", "-path.config", testpath/"config", "-path.data",
|
|
testpath/"data"
|
|
end
|
|
sleep 5
|
|
assert_match "hello", pipe_output("nc -l #{port}", "goodbye\n", 0)
|
|
sleep 5
|
|
assert_match "\"status\":\"up\"", (testpath/"heartbeat/heartbeat").read
|
|
end
|
|
end
|