Class: Fake::Server
- Inherits:
-
Object
- Object
- Fake::Server
- Defined in:
- lib/fake/server.rb
Instance Method Summary collapse
Instance Method Details
#start(rack_app, webrick_config) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/fake/server.rb', line 4 def start(rack_app, webrick_config) return unless @server_thread.nil? mutex = Mutex.new server_started = ConditionVariable.new @server_thread = Thread.new(rack_app, webrick_config) do |app, config| @server = WEBrick::HTTPServer.new(config) @server.mount "/", Rack::Handler::WEBrick, app server_started.signal @server.start end mutex.synchronize do server_started.wait(mutex) end end |
#stop ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/fake/server.rb', line 19 def stop unless @server_thread.nil? @server.shutdown @server_thread.join if @server_thread.alive? @server_thread = nil end end |