Class: UU::OS::Util::EmbeddedApplicationServer
- Inherits:
-
EmbeddedHTTPServer
- Object
- EmbeddedHTTPServer
- UU::OS::Util::EmbeddedApplicationServer
- Defined in:
- uu_os_connection-server-2.3.1/lib/uu/os/util/embedded_application_server.rb
Overview
Simple application server based on EmbeddedHTTPServer to be used mainly for testing purposes.
Constant Summary
Instance Attribute Summary
Attributes inherited from EmbeddedHTTPServer
#base_url, #context, #host, #port
Instance Method Summary (collapse)
-
- (EmbeddedApplicationServer) initialize(app_dir = Dir.pwd, options = {})
constructor
Creates new instance of server.
-
- (void) start
Starts server.
Methods inherited from EmbeddedHTTPServer
#register_servlet, #shutdown, #status, #stop
Constructor Details
- (EmbeddedApplicationServer) initialize(app_dir = Dir.pwd, options = {})
Creates new instance of server.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'uu_os_connection-server-2.3.1/lib/uu/os/util/embedded_application_server.rb', line 32 def initialize(app_dir = Dir.pwd, = {}) app_dir, = Dir.pwd, app_dir if app_dir.kind_of?(Hash) ENV['RACK_ENV'] = 'test' if ENV['RACK_ENV'].nil? super() @app_dir = File.(app_dir) @options = .dup @options[:config] ||= './config.ru' @options[:server] ||= 'embedded' @options[:server_instance] = @server Rack::Handler.register('embedded', EmbeddedHandler) end |
Instance Method Details
- (void) start
This method returns an undefined value.
Starts server.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'uu_os_connection-server-2.3.1/lib/uu/os/util/embedded_application_server.rb', line 46 def start @thread = Thread.new { Thread.current.abort_on_exception = true Thread.current[:BASE_URL] = base_url Thread.current[:SERVER_CFG] = @options[:server_cfg] Dir.chdir(@app_dir) Rack::Server.start(@options) } while @server.status != :Running Thread.pass unless @thread.alive? @thread.join raise end end return end |