Class: Gloo::WebSvr::Server
- Inherits:
-
Object
- Object
- Gloo::WebSvr::Server
- Defined in:
- lib/gloo/web_svr/server.rb
Instance Method Summary collapse
-
#call(env) ⇒ Object
Handle a request for a resource.
-
#initialize(engine, handler, config = nil, ssl_config = nil) ⇒ Server
constructor
Set up the web server.
-
#start ⇒ Object
Start the web server.
-
#stop ⇒ Object
Stop the web server.
Constructor Details
#initialize(engine, handler, config = nil, ssl_config = nil) ⇒ Server
Set up the web server.
37 38 39 40 41 42 43 44 45 |
# File 'lib/gloo/web_svr/server.rb', line 37 def initialize( engine, handler, config = nil, ssl_config = nil ) @config = config ? config : Gloo::WebSvr::Config.new @ssl_config = ssl_config @engine = engine @log = @engine.log @handler = handler @log.debug 'Gloo web server intialized…' end |
Instance Method Details
#call(env) ⇒ Object
Handle a request for a resource.
91 92 93 94 95 96 97 98 99 |
# File 'lib/gloo/web_svr/server.rb', line 91 def call( env ) request = Gloo::WebSvr::Request.new( @engine, @handler, env ) request.log response = request.process response.log if response return response ? response.result : nil end |
#start ⇒ Object
Start the web server.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/gloo/web_svr/server.rb', line 55 def start opts = { :Port => @config.port, :Host => @config.host } Thread.abort_on_exception = true @server_thread = Thread.new { Rack::Handler::Thin.run( self, **=opts ) do |server| if @ssl_config server.ssl = true server. = @ssl_config end end } @log.debug 'Web server has started.' end |
#stop ⇒ Object
Stop the web server
75 76 77 78 79 80 81 |
# File 'lib/gloo/web_svr/server.rb', line 75 def stop @log.debug 'Stopping the web server…' @server_thread.kill @log.debug 'The web server has been stopped.' end |