74 lines
2.2 KiB
Ruby
74 lines
2.2 KiB
Ruby
class Cortex < Formula
|
|
desc "Long term storage for Prometheus"
|
|
homepage "https://cortexmetrics.io/"
|
|
url "https://github.com/cortexproject/cortex/archive/v1.3.0.tar.gz"
|
|
sha256 "5354cbed3670e566b8f01609fc8e160640a66d034ccad144c77b8e315feadea8"
|
|
license "Apache-2.0"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "2682468002977085500804931b9d8867e6ba8bc6c4c717f957d7bb6f4e62a899" => :catalina
|
|
sha256 "03515e6d66aab6e1ba7cf364d9e4ef20fad156dbed855abc40a17b4686e26c3a" => :mojave
|
|
sha256 "157de4fbc1e9941cf47753d204b2cd48636e1654e15dff1f3a3709f58e53fd86" => :high_sierra
|
|
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
|