mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 06:37:19 -04:00
- don't assume we're running from the jar.
This commit is contained in:
parent
54cbe28356
commit
01497ad54e
1 changed files with 8 additions and 6 deletions
|
@ -35,12 +35,14 @@ class LogStash::Filters::UserAgent < LogStash::Filters::Base
|
|||
@parser = UserAgentParser::Parser.new()
|
||||
rescue Exception => e
|
||||
begin
|
||||
# Running from a flatjar which has a different layout
|
||||
jar_path = [__FILE__.split("!").first, "/vendor/ua-parser/regexes.yaml"].join("!")
|
||||
#tmp_file = Tempfile.new('logstash-uaparser-regexes')
|
||||
#tmp_file.write(File.read(jar_path))
|
||||
#tmp_file.close # this file is reaped when ruby exits
|
||||
@parser = UserAgentParser::Parser.new(:patterns_path => jar_path)
|
||||
if __FILE__ =~ /file:\/.*\.jar!/
|
||||
# Running from a flatjar which has a different layout
|
||||
regexes_file = [__FILE__.split("!").first, "/vendor/ua-parser/regexes.yaml"].join("!")
|
||||
@parser = UserAgentParser::Parser.new(:patterns_path => jar_path)
|
||||
else
|
||||
# assume operating from the git checkout
|
||||
@parser = UserAgentParser::Parser.new(:patterns_path => "vendor/ua-parser/regexes.yaml")
|
||||
end
|
||||
rescue => ex
|
||||
raise "Failed to cache, due to: #{ex}\n#{ex.backtrace}"
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue