Class: ThreeScale::Backend::Server::Puma
- Inherits:
-
Object
- Object
- ThreeScale::Backend::Server::Puma
- Extended by:
- Utils
- Defined in:
- lib/3scale/backend/server/puma.rb
Constant Summary collapse
- CONFIG =
'config/puma.rb'
- CONTROL_SOCKET =
'3scale_backend.sock'
- STATE =
'3scale_backend.state'
- EXPANDED_ROOT_PATH =
File.(File.join(*Array.new(5, '..')), __FILE__)
Class Method Summary collapse
- .help(global_options, options, args) ⇒ Object
- .restart(global_options, options, args) ⇒ Object
- .socket_state_dir(env, default_dir) ⇒ Object
- .start(global_options, options, args) ⇒ Object
Methods included from Utils
Class Method Details
.help(global_options, options, args) ⇒ Object
53 54 55 |
# File 'lib/3scale/backend/server/puma.rb', line 53 def self.help(, , args) system('puma --help') end |
.restart(global_options, options, args) ⇒ Object
43 44 45 |
# File 'lib/3scale/backend/server/puma.rb', line 43 def self.restart(, , args) build_pumactl_cmdline([:'phased-restart'] ? 'phased-restart' : 'restart', , , args) end |
.socket_state_dir(env, default_dir) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/3scale/backend/server/puma.rb', line 14 def self.socket_state_dir(env, default_dir) if ['development', 'test'].include?(env) && File.writable?(default_dir) default_dir else File.join('', 'tmp') end end |
.start(global_options, options, args) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/3scale/backend/server/puma.rb', line 22 def self.start(, , args) manifest = [:manifest] return unless manifest argv = ['puma'] argv_add argv, [:daemonize], '-d' argv_add argv, [:port], '-p', [:port] argv_add argv, [:logfile], '--redirect-stdout', [:logfile] argv_add argv, [:errorfile], '--redirect-stderr', [:errorfile] argv << '--redirect-append' if [[:logfile], [:errorfile]].any? argv_add argv, [:pidfile], '--pidfile', [:pidfile] # workaround Puma bug not phase-restarting correctly if no --dir is specified argv_add argv, true, '--dir', [:directory] ? [:directory] : EXPANDED_ROOT_PATH argv_add argv, true, '-C', CONFIG ss_dir = socket_state_dir([:environment], [:directory] || EXPANDED_ROOT_PATH) argv_add argv, true, '-S', File.join(ss_dir, STATE) argv_add argv, true, '--control', "unix://#{File.join(ss_dir, CONTROL_SOCKET)}" server_model = manifest[:server_model] argv_add argv, true, '-w', server_model[:workers].to_s argv_add argv, true, '-t', "#{server_model[:min_threads]}:#{server_model[:max_threads]}" end |