Sha256: 7e6799ca65b6aef05cce79ce5f0d92f8fbac4968e26e802c18c2a44842a71894

Contents?: true

Size: 1.21 KB

Versions: 5

Compression:

Stored size: 1.21 KB

Contents

require 'aruba/api'
require 'aruba/process'

module Aruba

  module Api

    # this is a horrible hack, to make sure that it's done what it needs to do
    # before we do our next step
    def keep_trying(timeout=10, tries=0)
      announce "Try: #{tries}" if @announce_env
      yield
    rescue RSpec::Expectations::ExpectationNotMetError
      if tries < timeout
        sleep 1
        tries += 1
        retry
      else
        raise
      end
    end

    def run_background(cmd)
      @background = run(cmd)
    end

    def send_signal(cmd, signal)
      announce_or_puts "$ kill -#{signal} #{processes[cmd].pid}" if @announce_env
      processes[cmd].send_signal signal
    end

    def background_pid
      @pid_from_pidfile || @background.pid
    end

    def interpolate_background_pid(string)
      interpolated = string.gsub('$PID', background_pid.to_s)
      announce_or_puts interpolated if @announce_env
      interpolated
    end

    def kill_all_processes!
      stop_processes!
    rescue
      processes.each {|cmd,process| send_signal(cmd, 'KILL') }
      raise
    end

  end

  class Process
    def pid
      @process.pid
    end
    def send_signal signal
      @process.send :send_signal, signal
    end
  end

end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
vitobotta-resque-pool-0.3.2.dev features/support/aruba_daemon_support.rb
vitobotta-resque-pool-0.3.1.dev features/support/aruba_daemon_support.rb
vitobotta-resque-pool-0.3.0.dev features/support/aruba_daemon_support.rb
resque-pool-0.3.0.beta.1 features/support/aruba_daemon_support.rb
resque-pool-0.2.0 features/support/aruba_daemon_support.rb