Parent

Files

Padrino::Server

This module builds a Padrino server to run the project based on available handlers.

Public Class Methods

new(options, app) click to toggle source
# File lib/padrino-core/server.rb, line 37
def initialize(options, app)
  @options, @app = options, app
end
start(app, opts={}) click to toggle source

Starts the application on the available server with specified options.

# File lib/padrino-core/server.rb, line 23
def self.start(app, opts={})
  options = {}.merge(opts) # We use a standard hash instead of Thor::CoreExt::HashWithIndifferentAccess
  options.symbolize_keys!
  options[:Host] = options.delete(:host) || '0.0.0.0'
  options[:Port] = options.delete(:port) || 3000
  options[:AccessLog] = []
  if options[:daemonize]
    options[:pid] = options[:pid].blank? ? File.expand_path('tmp/pids/server.pid') : opts[:pid]
    FileUtils.mkdir_p(File.dirname(options[:pid]))
  end
  options[:server] = detect_rack_handler if options[:server].blank?
  new(options, app).start
end

Public Instance Methods

app() click to toggle source

The application the server will run.

# File lib/padrino-core/server.rb, line 51
def app
  @app
end
Also aliased as: wrapped_app
options() click to toggle source

The options specified to the server.

# File lib/padrino-core/server.rb, line 57
def options
  @options
end
start() click to toggle source

Starts the application on the available server with specified options.

# File lib/padrino-core/server.rb, line 42
def start
  puts "=> Padrino/#{Padrino.version} has taken the stage #{Padrino.env} at http://#{options[:Host]}:#{options[:Port]}"
  [:INT, :TERM].each { |sig| trap(sig) { exit } }
  super
ensure
  puts "<= Padrino has ended his set (crowd applauds)" unless options[:daemonize]
end
wrapped_app() click to toggle source
Alias for: app

[Validate]

Generated with the Darkfish Rdoc Generator 2.