Class: TP2::Server
- Inherits:
-
Object
- Object
- TP2::Server
- Defined in:
- lib/tp2/server.rb
Constant Summary collapse
- PENDING_REQUESTS_GRACE_PERIOD =
0.1
- PENDING_REQUESTS_TIMEOUT_PERIOD =
5
Class Method Summary collapse
Instance Method Summary collapse
- #app_from_opts ⇒ Object
-
#initialize(machine, opts, &app) ⇒ Server
constructor
A new instance of Server.
- #run ⇒ Object
Constructor Details
#initialize(machine, opts, &app) ⇒ Server
Returns a new instance of Server.
32 33 34 35 36 37 38 |
# File 'lib/tp2/server.rb', line 32 def initialize(machine, opts, &app) @machine = machine @opts = opts @app = app || app_from_opts @server_fds = [] @accept_fibers = [] end |
Class Method Details
.rack_app(opts) ⇒ Object
12 13 14 15 16 |
# File 'lib/tp2/server.rb', line 12 def self.rack_app(opts) raise "Missing app location" if !opts[:app_location] TP2::RackAdapter.load(opts[:app_location]) end |
.static_app(opts) ⇒ Object
28 29 |
# File 'lib/tp2/server.rb', line 28 def self.static_app(opts) end |
Instance Method Details
#app_from_opts ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/tp2/server.rb', line 40 def app_from_opts case @opts[:app_type] when nil, :tp2 Server.tp2_app(@machine, @opts) when :rack Server.rack_app(@opts) when :static Server.static_app(@opts) else raise "Invalid app type #{@opts[:app_type].inspect}" end end |
#run ⇒ Object
53 54 55 56 57 58 |
# File 'lib/tp2/server.rb', line 53 def run setup @machine.join(*@accept_fibers) rescue UM::Terminate graceful_shutdown end |