def read_log begin log_file = "#{LOG_PATH}/log" start_time = Time.now.utc Thread.current['active'] = true tree_path = [] open("| tail -n 0 -f #{log_file}") do |log| while Thread.current['active'] line = log.gets ... LOGGER.info(". ") sleep(0.25) end end rescue LOGGER.info("TRACKER ERROR: #{$!}") ensure LOGGER.info(path) end end thr = Thread.new {read_log} while check ... end thr['active'] = false thr.join