mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
- Add logparsed. Runs N processes with a parser for each process.
This commit is contained in:
parent
9b4e10e757
commit
25c06132ce
1 changed files with 55 additions and 0 deletions
55
bin/logparsed.rb
Normal file
55
bin/logparsed.rb
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
require 'rubygems'
|
||||||
|
require 'ruby-prof'
|
||||||
|
require 'lib/net/servers/parser'
|
||||||
|
|
||||||
|
#class String
|
||||||
|
#alias_method :orig_scan, :scan
|
||||||
|
#def scan(*args)
|
||||||
|
#raise
|
||||||
|
#return orig_scan(*args)
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
|
if ENV.has_key?("PROFILE")
|
||||||
|
RubyProf.start
|
||||||
|
end
|
||||||
|
|
||||||
|
def main(args)
|
||||||
|
|
||||||
|
if args.length != 1
|
||||||
|
puts "Usage: #{$0} configfile"
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
Thread::abort_on_exception = true
|
||||||
|
s = LogStash::Net::Servers::Parser.new(args[0])
|
||||||
|
s.run
|
||||||
|
|
||||||
|
if ENV.has_key?("PROFILE")
|
||||||
|
result = RubyProf.stop
|
||||||
|
printer = RubyProf::FlatPrinter.new(result)
|
||||||
|
printer.print(STDOUT, 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
procs = 4
|
||||||
|
if procs > 1
|
||||||
|
children = []
|
||||||
|
1.upto(procs) do |c|
|
||||||
|
pid = fork do
|
||||||
|
exit main(ARGV)
|
||||||
|
end
|
||||||
|
children << pid
|
||||||
|
end
|
||||||
|
|
||||||
|
while children.length > 0
|
||||||
|
pid = Process.waitpid(children[0], 0)
|
||||||
|
children.delete(pid)
|
||||||
|
puts "pid #{pid} died"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
exit main(ARGV)
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue