Class: Maze::DocumentServer

Inherits:
Object
  • Object
show all
Defined in:
lib/maze/document_server.rb

Overview

HTTP server for a given document root

Class Method Summary collapse

Class Method Details

.manual_startObject

Starts the document server “manually” (via a Cucumber step as opposed to command line option)



29
30
31
32
33
34
35
36
# File 'lib/maze/document_server.rb', line 29

def manual_start
  if !@thread.nil? && @thread.alive?
    $logger.warn 'Document Server has already been started on the command line, ignoring manual start'
    return
  end
  @manual_start = true
  start
end

.manual_stopObject



38
39
40
41
42
43
# File 'lib/maze/document_server.rb', line 38

def manual_stop
  return unless  @manual_start

  @thread.kill
  @manual_start = false
end

.startObject

Start the document server. This is intended to be called only once per test run. Use manual_start for finer grained control.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/maze/document_server.rb', line 11

def start
  @thread = Thread.new do
    options = {
      DocumentRoot: Maze.config.document_server_root,
      Port: Maze.config.document_server_port,
      Logger: $logger,
      AccessLog: []
    }
    options[:BindAddress] = Maze.config.document_server_bind_address unless Maze.config.document_server_bind_address.nil?
    server = WEBrick::HTTPServer.new(options)
    server.mount '/reflect', Servlets::ReflectiveServlet

    $logger.info "Starting document server for root: #{Maze.config.document_server_root}"
    server.start
  end
end