15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/test_server/cli/main.rb', line 15
def serve
TestServer.config = TestServer::Config.new(options[:config_file]) if options[:config_file]
TestServer.config.access_log = options[:access_log] if options[:access_log]
TestServer.config.log_level = options[:log_level] if options[:log_level]
TestServer.config.debug_mode = options[:debug_mode] if options[:debug_mode]
TestServer.config.environment = options[:environment] if options[:environment]
TestServer.config.worker_count = options[:worker_count] if options[:worker_count]
TestServer.config.listen = options[:listen] if options[:listen]
TestServer.config.lock
TestServer.ui_logger.level = TestServer.config.log_level
TestServer.enable_debug_mode if TestServer.config.debug_mode
TestServer.ui_logger.debug('Options: ' + options.to_s)
TestServer.ui_logger.debug("Config:\n" + TestServer.config.to_s)
command_klass = case options[:with].to_sym
when :puma
ServerCommands::Puma
when :rackup
ServerCommands::Rackup
else
ServerCommands::Rackup
end
command = command_klass.new(
listen: TestServer.config.listen,
environment: TestServer.config.environment,
worker_count: TestServer.config.worker_count,
)
ENV['DEBUG'] = TestServer.config.debug_mode.to_s if TestServer.config.debug_mode
ENV['ACCESS_LOG'] = TestServer.config.access_log.to_s if TestServer.config.access_log
ENV['LOG_LEVEL'] = TestServer.config.log_level.to_s if TestServer.config.log_level
Server.new(command).start
end
|