control (God)

    # File lib/god.rb, line 391
      def self.control(name, command)
        # get the list of items
        items = Array(self.watches[name] || self.groups[name]).dup

        jobs = []

        # do the command
        case command
          when "start", "monitor"
            items.each { |w| jobs << Thread.new { w.monitor if w.state != :up } }
          when "restart"
            items.each { |w| jobs << Thread.new { w.move(:restart) } }
          when "stop"
            items.each { |w| jobs << Thread.new { w.unmonitor.action(:stop) if w.state != :unmonitored } }
          when "unmonitor"
            items.each { |w| jobs << Thread.new { w.unmonitor if w.state != :unmonitored } }
          when "remove"
            items.each { |w| self.unwatch(w) }
          else
            raise InvalidCommandError.new
        end

        jobs.each { |j| j.join }

        items.map { |x| x.name }
      end