class Firehose::Server::App

Configure servers that are booted with-out going through Rack. This is mostly used by the ‘firehose server` CLI command or for testing. Production configurations are likely to boot with custom rack configurations.

Public Class Methods

new(opts={}) click to toggle source
# File lib/firehose/server/app.rb, line 7
def initialize(opts={})
  @port   = opts[:port]   || Firehose::URI.port
  @host   = opts[:host]   || Firehose::URI.host
  @server = opts[:server] || :rainbows

  Firehose.logger.info "Starting #{Firehose::VERSION} '#{Firehose::CODENAME}', in #{ENV['RACK_ENV']}"
end

Public Instance Methods

start() click to toggle source
# File lib/firehose/server/app.rb, line 15
def start
  self.send("start_#{@server}")
end

Private Instance Methods

start_rainbows() click to toggle source

Boot the Firehose server with the Rainbows app server.

# File lib/firehose/server/app.rb, line 21
def start_rainbows
  require 'rainbows'
  Faye::WebSocket.load_adapter('rainbows')

  rackup = Unicorn::Configurator::RACKUP
  rackup[:port] = @port if @port
  rackup[:host] = @host if @host
  rackup[:set_listener] = true
  opts = rackup[:options]
  opts[:config_file] = File.expand_path('../../../../config/rainbows.rb', __FILE__)

  server = Rainbows::HttpServer.new(Firehose::Rack::App.new, opts)
  server.start.join
end
start_thin() click to toggle source

Boot the Firehose server with the Thin app server.

# File lib/firehose/server/app.rb, line 37
def start_thin
  require 'thin'

  Faye::WebSocket.load_adapter('thin')

  # TODO: See if we can just set Thin to use Firehose.logger instead of
  #       printing out messages by itself.
  Thin::Logging.silent = true if Firehose.logger.level == Logger::ERROR

  server = Thin::Server.new(@host, @port) do
    run Firehose::Rack::App.new
  end.start
end