300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
|
# File 'lib/crash_monkey/monkey_runner.rb', line 300
def watch_syslog
STDOUT.sync = true
stdin, stdout, stderr = Open3.popen3(grep_syslog)
log_filename = "#{result_base_dir}/console.log"
thread = Thread.new do
File.open(log_filename, 'a') do |output|
begin
while true
line = stdout.readline
output.write(line) if line.include?(app_name)
end
rescue IOError
log 'tail finished: system.log'
end
end
end
yield
sleep 3
stdout.close; stderr.close; stdin.close
thread.join
FileUtils.makedirs(result_dir) unless File.exists?(result_dir)
if File.exists?(log_filename)
FileUtils.move(log_filename, console_log_path)
end
end
|