Class: TestServer
Constant Summary collapse
- PORT =
1234
- @@logger =
nil
- @@server_thread =
nil
Class Method Summary collapse
- .logger ⇒ Object
- .logger=(logger) ⇒ Object
- .shutdown ⇒ Object
- .startup(port = PORT, options = {}) ⇒ Object
Class Method Details
.logger ⇒ Object
95 96 97 |
# File 'lib/wdd-ruby-ext/utils/test_server.rb', line 95 def self.logger @@logger end |
.logger=(logger) ⇒ Object
99 100 101 |
# File 'lib/wdd-ruby-ext/utils/test_server.rb', line 99 def self.logger= logger @@logger = logger end |
.shutdown ⇒ Object
119 120 121 122 123 124 125 |
# File 'lib/wdd-ruby-ext/utils/test_server.rb', line 119 def self.shutdown return unless @@server_thread @@server_thread.kill @@server_thread.join logger.info "TestServer stopped." @@server_thread = nil end |
.startup(port = PORT, options = {}) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/wdd-ruby-ext/utils/test_server.rb', line 103 def self.startup( port=PORT, ={} ) @@logger ||= Logger.new(STDOUT) @@logger.level = [:logger_level] || Logger::DEBUG @@multi_threaded = [:multi_threaded] || false return if @@server_thread @@server_thread = Thread.new do begin EM.run do EM.start_server "0.0.0.0", port, TestServerModule end rescue Interrupt end end logger.info "TestServer listening on port #{port}." end |