features/support/daemons.rb in flapjack-0.7.29 vs features/support/daemons.rb in flapjack-0.7.30

- old
+ new

@@ -21,10 +21,16 @@ def write_file(file_name, file_content) _create_file(file_name, file_content, false) end +def create_fifo(fifo_name) + unless File.pipe?(fifo_name) + system("mkfifo #{fifo_name}") + end +end + def _create_file(file_name, file_content, check_presence) in_current_dir do raise "expected #{file_name} to be present" if check_presence && !File.file?(file_name) _mkdir(File.dirname(file_name)) File.open(file_name, 'w') { |f| f << file_content } @@ -72,20 +78,24 @@ return unless cutoff_time.nil? || (file_time.to_i >= cutoff_time.to_i) [file_time, File.read(pid_file).strip.to_i] end def spawn_process(command, opts={}) + @daemons_output ||= [] + @daemons_exit_status ||= [] + puts yellow("Running: #{command}") if @debug process_h = nil file = opts[:daemon_pidfile] if file time = Time.now attempts = 0 - `#{command}` + @daemons_output << `#{command}` + @daemons_exit_status << $? while attempts < 50 time_and_pid = time_and_pid_from_file(file, time) if time_and_pid process_h = {:pid => time_and_pid.last, :command => command}