Class: Tipsy::Server
- Inherits:
-
Object
- Object
- Tipsy::Server
- Defined in:
- lib/tipsy/server.rb
Overview
Rack server implementation. Tipsy::Server will run any Rack::Builder compatable format. If thin or puma are availble, they will be used first, and in that order, with a fallback to webrick.
Defined Under Namespace
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Class Method Summary collapse
- .banner(server, port) ⇒ Object
-
.run!(app, options) ⇒ Object
Run the Rack::Builder application.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize ⇒ Server
constructor
A new instance of Server.
Constructor Details
#initialize ⇒ Server
Returns a new instance of Server.
57 58 59 |
# File 'lib/tipsy/server.rb', line 57 def initialize @last_update = Time.now end |
Instance Attribute Details
#request ⇒ Object (readonly)
Returns the value of attribute request.
11 12 13 |
# File 'lib/tipsy/server.rb', line 11 def request @request end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
11 12 13 |
# File 'lib/tipsy/server.rb', line 11 def response @response end |
Class Method Details
.banner(server, port) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/tipsy/server.rb', line 49 def (server, port) puts "" Tipsy.logger.info " Tipsy #{Tipsy::VERSION}", :green Tipsy.logger.info " Started from #{Tipsy.root}" Tipsy.logger.info " using #{server}, port #{port}" end |
.run!(app, options) ⇒ Object
Run the Rack::Builder application
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/tipsy/server.rb', line 18 def run!(app, ) begin handler = Rack::Handler.get('thin') handler.run app, do |server| ("Thin (#{Thin::VERSION::STRING})", [:Port]) puts "-----------------------------------------------------------------" puts "" end exit(0) rescue LoadError begin handler = Rack::Handler.get('puma') handler.run app, do |server| ("Puma (#{Puma::Const::PUMA_VERSION})", [:Port]) puts "-----------------------------------------------------------------" puts "" end exit(0) rescue LoadError handler = Rack::Handler.get('webrick') handler.run app, do |server| ("Webrick", [:Port]) puts " To use Puma or Thin (recommended), add them to your Gemfile" puts "-----------------------------------------------------------------" puts "" trap("INT"){ server.shutdown } end end end end |