homebrew-core/Formula/cortex.rb

79 lines
2.5 KiB
Ruby

class Cortex < Formula
desc "Long term storage for Prometheus"
homepage "https://cortexmetrics.io/"
url "https://github.com/cortexproject/cortex/archive/v1.7.0.tar.gz"
sha256 "8454e424aabba01609fbcb5bfdaa7184779633893b00d1e6f3f697438213b74e"
license "Apache-2.0"
livecheck do
url :stable
strategy :github_latest
end
bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "836f0a9476579a1f2c3947ba2df819b3fac2e4eb26db4c27986728428230981e"
sha256 cellar: :any_skip_relocation, big_sur: "06559234d2550b71c6bea421d9a7e89e4bf93ec47add1a9754ee40b234c58b17"
sha256 cellar: :any_skip_relocation, catalina: "faf503740543dfd2d3fe98ef224485bb6244bc7e32921aae642b41acfc849a62"
sha256 cellar: :any_skip_relocation, mojave: "923b7834a300f8129899f602c4b464d1efc1724055f7ae83fe296bbefa27c345"
end
depends_on "go" => :build
def install
system "go", "build", *std_go_args, "./cmd/cortex"
cd "docs/configuration" do
inreplace "single-process-config.yaml", "/tmp", var
etc.install "single-process-config.yaml" => "cortex.yaml"
end
end
plist_options manual: "cortex -config.file=#{HOMEBREW_PREFIX}/etc/cortex.yaml"
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}/cortex</string>
<string>-config.file=#{etc}/cortex.yaml</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{var}</string>
<key>StandardErrorPath</key>
<string>#{var}/log/cortex.log</string>
<key>StandardOutPath</key>
<string>#{var}/log/cortex.log</string>
</dict>
</plist>
EOS
end
test do
port = free_port
cp etc/"cortex.yaml", testpath
inreplace "cortex.yaml" do |s|
s.gsub! "9009", port.to_s
s.gsub! var, testpath
end
fork { exec bin/"cortex", "-config.file=cortex.yaml", "-server.grpc-listen-port=#{free_port}" }
sleep 3
output = shell_output("curl -s localhost:#{port}/services")
assert_match "Running", output
end
end