Sha256: 77d8265cd939cb2810e98b4820738d0822635bbba7b5c9f612161e837a9a50d0

Contents?: true

Size: 937 Bytes

Versions: 19

Compression:

Stored size: 937 Bytes

Contents

module Bluepill
  class Group
    attr_accessor :name, :processes, :logger
    attr_accessor :process_logger
    
    def initialize(name, options = {})
      self.name = name
      self.processes = []
      self.logger = options[:logger]
    end
    
    def add_process(process)
      process.logger = self.logger.prefix_with(process.name)
      self.processes << process
    end
    
    def tick
      self.processes.each do |process|
        process.tick
      end
    end

    # proxied events
    [:start, :unmonitor, :stop, :restart, :boot!].each do |event|
      class_eval <<-END
        def #{event}(process_name = nil)
          threads = []
          self.processes.each do |process|
            next if process_name && process_name != process.name
            threads << Thread.new { process.handle_user_command("#{event}") }
          end
          threads.each { |t| t.join }
        end      
      END
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
bluepill-0.0.24 lib/bluepill/group.rb
bluepill-0.0.23 lib/bluepill/group.rb
bluepill-0.0.22 lib/bluepill/group.rb
bluepill-0.0.21 lib/bluepill/group.rb
bluepill-0.0.20 lib/bluepill/group.rb
bluepill-0.0.19 lib/bluepill/group.rb
bluepill-0.0.18 lib/bluepill/group.rb
bluepill-0.0.17 lib/bluepill/group.rb
bluepill-0.0.16 lib/bluepill/group.rb
bluepill-0.0.15 lib/bluepill/group.rb
bluepill-0.0.14 lib/bluepill/group.rb
bluepill-0.0.13 lib/bluepill/group.rb
bluepill-0.0.12 lib/bluepill/group.rb
bluepill-0.0.11 lib/bluepill/group.rb
bluepill-0.0.10 lib/bluepill/group.rb
bluepill-0.0.9 lib/bluepill/group.rb
bluepill-0.0.8 lib/bluepill/group.rb
bluepill-0.0.7 lib/bluepill/group.rb
bluepill-0.0.6 lib/bluepill/group.rb