Module: Proxy::Dynflow::Runner::ProcessManagerCommand

Defined in:
lib/smart_proxy_dynflow/runner/process_manager_command.rb

Instance Method Summary collapse

Instance Method Details

#closeObject



31
32
33
# File 'lib/smart_proxy_dynflow/runner/process_manager_command.rb', line 31

def close
  @process_manager&.close
end

#initialize_command(*command) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/smart_proxy_dynflow/runner/process_manager_command.rb', line 6

def initialize_command(*command)
  @process_manager = ProcessManager.new(command)
  set_process_manager_callbacks(@process_manager)
  @process_manager.start!
  if @process_manager.done? && @process_manager.status == 255
    publish_exception("Error running command '#{command.join(' ')}'", @process_manager.stderr.to_s)
  end
end

#refreshObject



26
27
28
29
# File 'lib/smart_proxy_dynflow/runner/process_manager_command.rb', line 26

def refresh
  @process_manager.process(timeout: 0.1)
  publish_exit_status(@process_manager.status) if @process_manager.done?
end

#set_process_manager_callbacks(pm) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/smart_proxy_dynflow/runner/process_manager_command.rb', line 15

def set_process_manager_callbacks(pm)
  pm.on_stdout do |data|
    publish_data(data, 'stdout')
    ''
  end
  pm.on_stderr do |data|
    publish_data(data, 'stderr')
    ''
  end
end