89 lines
3.0 KiB
Ruby
89 lines
3.0 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.17.0",
|
|
revision: "93708bd74e909e57ed5d9bea3cf2065f4cc43af3"
|
|
license "Apache-2.0"
|
|
head "https://github.com/elastic/beats.git", branch: "master"
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, arm64_monterey: "dae71ff1c9c8c73bed77122b4a36779fa7ac6d1348a67f396299b7b990ec836d"
|
|
sha256 cellar: :any_skip_relocation, arm64_big_sur: "ea02de25c6eda34df9b9a97a647049ab39cfb3e8913de6bf864f01ab3a1b3aeb"
|
|
sha256 cellar: :any_skip_relocation, monterey: "fc9d7d55e682734e6326650450ae600a63b31ad5ddd05f1522d36b054d104884"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "b651fae5767c4bbbf8ccff274d3cd9c942c27fa388d35eba5948f8cf9ba954ae"
|
|
sha256 cellar: :any_skip_relocation, catalina: "ad2e8ea13eff0e37ea4856a53b114930cb622d4f3e5bca56864cfbde895b3805"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "fe563395271ba49e765817998441b86a1c38368dcc1f9f7ed0d22c643b443949"
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
depends_on "mage" => :build
|
|
depends_on "python@3.10" => :build
|
|
uses_from_macos "netcat" => :test
|
|
|
|
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
|
|
# FIXME: This keeps stalling CI when tested as a dependent. See, for example,
|
|
# https://github.com/Homebrew/homebrew-core/pull/91712
|
|
return if OS.linux? && ENV["HOMEBREW_GITHUB_ACTIONS"].present?
|
|
|
|
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
|