Class: Rack::Handler::Unicorn

Inherits:
Object
  • Object
show all
Defined in:
lib/unicorn/padrino.rb

Constant Summary collapse

DEFAULT_PATHS =
%w[config/unicorn.rb config/{env}/unicorn.rb]
DEFAULT_OPTIONS =
{ timeout: 31 * 24 * 60 * 60 }

Class Method Summary collapse

Class Method Details

.run(app, options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/unicorn/padrino.rb', line 22

def run(app, options = {})
  unicorn_options = {}
  
  if config_file = detect_configuration_file
    unicorn_options[:config_file] = "#{root}/#{config_file}"
  else
    unicorn_options.merge!(DEFAULT_OPTIONS)
    (unicorn_options[:listeners] = []) << "#{options[:Host]}:#{options[:Port]}"
  end
  
  if options[:daemonize]
    unicorn_options[:pid] = options[:pid]
    ::Unicorn::Launcher.daemonize!(unicorn_options)
  end
  ::Unicorn::HttpServer.new(app, unicorn_options).start.join
end