Sha256: c4569ff7f5a24f04c8838d2532ba90a7aed301fa4f088630e6cafae8d6059f49

Contents?: true

Size: 656 Bytes

Versions: 1

Compression:

Stored size: 656 Bytes

Contents

module MultiDaemons
  # To control daemons
  class Controller
    attr_accessor :daemons, :options

    def initialize(daemons, options = {})
      @daemons = daemons
      @options = options
    end

    def start
      daemons.each(&:start)
    end

    def stop
      pids = []
      pid_files = []
      daemons.each do |daemon|
        daemon.multiple = true
        daemon.stop
        pids << daemon.pids
        pid_files << daemon.pid_file
      end
      Pid.force_kill(pids.flatten, force_kill_timeout)
      PidStore.cleanup(pid_files)
    end

    private

    def force_kill_timeout
      options[:force_kill_timeout] || 30
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
multi_daemons-0.1.0 lib/multi_daemons/controller.rb