108 lines
3.3 KiB
Ruby
108 lines
3.3 KiB
Ruby
class Logstash < Formula
|
|
desc "Tool for managing events and logs"
|
|
homepage "https://www.elastic.co/products/logstash"
|
|
url "https://github.com/elastic/logstash/archive/v7.15.0.tar.gz"
|
|
sha256 "df6f1c322cbf979e0444263196377325ef8454dbdcfa9cf1f25c3721763ae6b6"
|
|
license "Apache-2.0"
|
|
version_scheme 1
|
|
head "https://github.com/elastic/logstash.git"
|
|
|
|
livecheck do
|
|
url :stable
|
|
regex(/^v?(\d+(?:\.\d+)+)$/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any, big_sur: "52cb47a3641e80a4da46830d028b946810b6281efbd588b2ca9d850d70362fbc"
|
|
sha256 cellar: :any, catalina: "d799d30943fd733b2bb339cacd54c10b3fef5661a716212cfd482e602a6f0e7d"
|
|
sha256 cellar: :any, mojave: "50495a782317b0068ec2be3b99495e83733ce8806bc677f229de5c7f426d410a"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "41cacfcd57a1f333596508ee85a721de1b8800a11502601083d5a4c4038d0475"
|
|
end
|
|
|
|
depends_on "openjdk@11"
|
|
|
|
uses_from_macos "ruby" => :build
|
|
|
|
def install
|
|
# remove non open source files
|
|
rm_rf "x-pack"
|
|
ENV["OSS"] = "true"
|
|
|
|
# Build the package from source
|
|
system "rake", "artifact:no_bundle_jdk_tar"
|
|
# Extract the package to the current directory
|
|
mkdir "tar"
|
|
system "tar", "--strip-components=1", "-xf", Dir["build/logstash-*.tar.gz"].first, "-C", "tar"
|
|
cd "tar"
|
|
|
|
inreplace "bin/logstash",
|
|
%r{^\. "\$\(cd `dirname \$\{SOURCEPATH\}`/\.\.; pwd\)/bin/logstash\.lib\.sh"},
|
|
". #{libexec}/bin/logstash.lib.sh"
|
|
inreplace "bin/logstash-plugin",
|
|
%r{^\. "\$\(cd `dirname \$0`/\.\.; pwd\)/bin/logstash\.lib\.sh"},
|
|
". #{libexec}/bin/logstash.lib.sh"
|
|
inreplace "bin/logstash.lib.sh",
|
|
/^LOGSTASH_HOME=.*$/,
|
|
"LOGSTASH_HOME=#{libexec}"
|
|
|
|
# Delete Windows and other Arch/OS files
|
|
rm Dir["bin/*.bat"]
|
|
os = if OS.mac?
|
|
"Darwin"
|
|
else
|
|
"x86_64-Linux"
|
|
end
|
|
Dir["vendor/jruby/lib/jni/*"].each do |path|
|
|
rm_r path unless path.include? os
|
|
end
|
|
|
|
libexec.install Dir["*"]
|
|
|
|
# Move config files into etc
|
|
(etc/"logstash").install Dir[libexec/"config/*"]
|
|
(libexec/"config").rmtree
|
|
|
|
bin.install libexec/"bin/logstash", libexec/"bin/logstash-plugin"
|
|
bin.env_script_all_files libexec/"bin", Language::Java.overridable_java_home_env("11")
|
|
end
|
|
|
|
def post_install
|
|
ln_s etc/"logstash", libexec/"config"
|
|
end
|
|
|
|
def caveats
|
|
<<~EOS
|
|
Configuration files are located in #{etc}/logstash/
|
|
EOS
|
|
end
|
|
|
|
service do
|
|
run opt_bin/"logstash"
|
|
keep_alive false
|
|
working_dir var
|
|
log_path var/"log/logstash.log"
|
|
error_log_path var/"log/logstash.log"
|
|
end
|
|
|
|
test do
|
|
# workaround https://github.com/elastic/logstash/issues/6378
|
|
(testpath/"config").mkpath
|
|
["jvm.options", "log4j2.properties", "startup.options"].each do |f|
|
|
cp prefix/"libexec/config/#{f}", testpath/"config"
|
|
end
|
|
(testpath/"config/logstash.yml").write <<~EOS
|
|
path.queue: #{testpath}/queue
|
|
EOS
|
|
(testpath/"data").mkpath
|
|
(testpath/"logs").mkpath
|
|
(testpath/"queue").mkpath
|
|
|
|
data = "--path.data=#{testpath}/data"
|
|
logs = "--path.logs=#{testpath}/logs"
|
|
settings = "--path.settings=#{testpath}/config"
|
|
|
|
output = pipe_output("#{bin}/logstash -e '' #{data} #{logs} #{settings} --log.level=fatal", "hello world\n")
|
|
assert_match "hello world", output
|
|
end
|
|
end
|