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
|
# File 'lib/crabfarm/support/custom_puma.rb', line 15
def self.run(_app, _options = {})
_options = DEFAULT_OPTIONS.merge(_options)
_app = Rack::CommonLogger.new(_app, STDOUT) if _options[:Verbose]
ENV['RACK_ENV'] = _options[:environment].to_s if _options[:environment]
server = Puma::Server.new(_app)
min, max = _options[:Threads].split(':', 2)
puts "Puma #{::Puma::Const::PUMA_VERSION} starting..."
puts "* Min threads: #{min}, max threads: #{max}"
puts "* Environment: #{ENV['RACK_ENV']}"
if _options[:Host].start_with? 'unix://'
puts "* Listening on #{_options[:Host]}"
server.add_unix_listener _options[:Host][7..-1]
else
puts "* Listening on tcp://#{_options[:Host]}:#{_options[:Port]}"
server.add_tcp_listener _options[:Host], _options[:Port]
end
server.min_threads = min
server.max_threads = max
begin
server.run.join
rescue Interrupt
puts "* Gracefully stopping, waiting for requests to finish"
server.stop(true)
puts "* Goodbye!"
end
end
|