Module: EM
- Defined in:
- lib/eventmachine/profile.rb,
lib/eventmachine/pid_poller.rb,
lib/eventmachine/line_processor.rb,
lib/eventmachine/process_buffer.rb,
lib/eventmachine/process_buffer/version.rb,
lib/eventmachine/process_buffer/watcher.rb
Defined Under Namespace
Modules: PidPoller, ProcessBuffer Classes: LineProcessor
Class Method Summary collapse
- .buffer_process(pid_file, working_directory, command, environment, handler, *args, &block) ⇒ Object
- .profile ⇒ Object
Class Method Details
.buffer_process(pid_file, working_directory, command, environment, handler, *args, &block) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/eventmachine/process_buffer.rb', line 66 def self.buffer_process pid_file, working_directory, command, environment, handler, *args, &block pipe_directory = working_directory FileUtils.mkdir_p working_directory if File.exist?(pid_file) pid = File.read(pid_file).strip.to_i if Process.alive?(pid) puts "found running process pid=#{pid} pid_file=#{pid_file}" ProcessBuffer.attach_to_process pid, pipe_directory, working_directory, pid_file, command, handler, *args, &block else puts "found dead process pid=#{pid} pid_file=#{pid_file}" ProcessBuffer.start_process pipe_directory, working_directory, pid_file, command, environment, handler, *args, &block end else ProcessBuffer.start_process pipe_directory, working_directory, pid_file, command, environment, handler, *args, &block end end |
.profile ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/eventmachine/profile.rb', line 2 def self.profile started_at = Time.now iterations = 0 iteration_started_at = Time.now EM.add_periodic_timer(1) do iterations += 1 total_delta = ((Time.now - started_at) - iterations) iteration_delta = (Time.now - iteration_started_at) - 1 iteration_started_at = Time.now puts "iteration: #{iteration_delta.round(4)} total:#{total_delta.round(4)}" end end |