Class: Padrino::Server
- Inherits:
-
Rack::Server
- Object
- Rack::Server
- Padrino::Server
- Defined in:
- lib/padrino-core/server.rb
Overview
This module builds a Padrino server to run the project based on available handlers.
Constant Summary collapse
- DEFAULT_ADDRESS =
{ :Host => '127.0.0.1', :Port => 3000 }
- Handlers =
Server Handlers
[:thin, :puma, :'spider-gazelle', :mongrel, :trinidad, :webrick]
Class Method Summary collapse
-
.start(app, options = {}) ⇒ Object
Starts the application on the available server with specified options.
Instance Method Summary collapse
-
#app ⇒ Object
(also: #wrapped_app)
The application the server will run.
-
#initialize(options, app) ⇒ Server
constructor
A new instance of Server.
- #options ⇒ Object
-
#start ⇒ Object
Starts the application on the available server with specified options.
Constructor Details
#initialize(options, app) ⇒ Server
Returns a new instance of Server.
52 53 54 |
# File 'lib/padrino-core/server.rb', line 52 def initialize(, app) @options, @app = , app end |
Class Method Details
.start(app, options = {}) ⇒ Object
Starts the application on the available server with specified options.
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/padrino-core/server.rb', line 41 def self.start(app, ={}) = Utils.symbolize_keys(.to_hash) .update((.delete(:options))) .update(detect_address()) [:pid] = prepare_pid([:pid]) if [:daemonize] [:server] ||= detect_rack_handler # disable Webrick AccessLog [:AccessLog] = [] new(, app).start end |
Instance Method Details
#app ⇒ Object Also known as: wrapped_app
The application the server will run.
68 69 70 |
# File 'lib/padrino-core/server.rb', line 68 def app @app end |
#options ⇒ Object
73 74 75 |
# File 'lib/padrino-core/server.rb', line 73 def @options end |
#start ⇒ Object
Starts the application on the available server with specified options.
57 58 59 60 61 62 63 64 65 |
# File 'lib/padrino-core/server.rb', line 57 def start puts "=> Padrino/#{Padrino.version} has taken the stage #{Padrino.env} at http://#{[:Host]}:#{[:Port]}" [:INT, :TERM].each { |sig| trap(sig) { exit } } super do |server| server.threaded = true if server.respond_to?(:threaded=) end ensure puts "<= Padrino leaves the gun, takes the cannoli" unless [:daemonize] end |