Class JettyRails::Runner
In: lib/jetty_rails/runner.rb
Parent: Object

Methods

add_server   new   start  

Attributes

servers  [R] 

Public Class methods

[Source]

# File lib/jetty_rails/runner.rb, line 8
    def initialize(config = {})
      @servers = {}
      config.symbolize_keys!
      if config[:servers].nil?
        add_server(config) 
      else
        config[:servers].each do |server_config|
          server_config.symbolize_keys!
          server_config.reverse_merge!(config)
          server_config.delete(:servers)
          add_server(server_config)
        end
      end
    end

Public Instance methods

[Source]

# File lib/jetty_rails/runner.rb, line 23
    def add_server(config = {})
      server = JettyRails::Server.new(config)
      @servers[server.config[:port]] = server
    end

[Source]

# File lib/jetty_rails/runner.rb, line 28
    def start
      server_threads = ThreadGroup.new
      @servers.each do |base, server|
        log("Starting server #{base}")
        server_threads.add(Thread.new do
          server.start
        end)
      end
      
      server_threads.list.each {|thread| thread.join } unless server_threads.list.empty?
    end

[Validate]