-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathlogstash-oss.rb
95 lines (84 loc) · 3.13 KB
/
logstash-oss.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
class LogstashOss < Formula
desc "Tool for managing events and logs"
homepage "https://www.elastic.co/products/logstash"
url "https://artifacts.elastic.co/downloads/logstash/logstash-oss-7.17.4-darwin-x86_64.tar.gz?tap=elastic/homebrew-tap"
version "7.17.4"
sha256 "655ab873e16257827f884f67b66d62c4da40a895d06206faa435615ad0a56796"
conflicts_with "logstash"
conflicts_with "logstash-full"
def install
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}"
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", {})
system "find", "#{libexec}/jdk.app/Contents/Home/bin", "-type", "f", "-exec", "codesign", "-f", "-s", "-", "{}", ";"
end
def post_install
# Make sure runtime directories exist
ln_s etc/"logstash", libexec/"config"
end
def caveats; <<~EOS
Please read the getting started guide located at:
https://www.elastic.co/guide/en/logstash/current/getting-started-with-logstash.html
EOS
end
plist_options :manual => "logstash"
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>
<false/>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/logstash</string>
</array>
<key>EnvironmentVariables</key>
<dict>
</dict>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{var}</string>
<key>StandardErrorPath</key>
<string>#{var}/log/logstash.log</string>
<key>StandardOutPath</key>
<string>#{var}/log/logstash.log</string>
</dict>
</plist>
EOS
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