mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Add reload_worker_directory
This commit is contained in:
parent
75d60d019c
commit
48b50a312f
4 changed files with 25 additions and 3 deletions
|
@ -48,6 +48,13 @@ module Puma
|
|||
return rack_response(200, OK_STATUS)
|
||||
end
|
||||
|
||||
when /\/reload-worker-directory$/
|
||||
if !@cli.reload_worker_directory
|
||||
return rack_response(404, '{ "error": "reload_worker_directory not available" }')
|
||||
else
|
||||
return rack_response(200, OK_STATUS)
|
||||
end
|
||||
|
||||
when /\/stats$/
|
||||
return rack_response(200, @cli.stats)
|
||||
else
|
||||
|
|
|
@ -522,6 +522,10 @@ module Puma
|
|||
@runner.restart
|
||||
end
|
||||
|
||||
def reload_worker_directory
|
||||
@runner.reload_worker_directory if @runner.respond_to?(:reload_worker_directory)
|
||||
end
|
||||
|
||||
def phased_restart
|
||||
unless @runner.respond_to?(:phased_restart) and @runner.phased_restart
|
||||
log "* phased-restart called but not available, restarting normally."
|
||||
|
|
|
@ -98,9 +98,9 @@ module Puma
|
|||
end
|
||||
|
||||
def next_worker_index
|
||||
all_positions = 0...@options[:workers]
|
||||
all_positions = 0...@options[:workers]
|
||||
occupied_positions = @workers.map { |w| w.index }
|
||||
available_positions = all_positions.to_a - occupied_positions
|
||||
available_positions = all_positions.to_a - occupied_positions
|
||||
available_positions.first
|
||||
end
|
||||
|
||||
|
@ -248,6 +248,13 @@ module Puma
|
|||
wakeup!
|
||||
end
|
||||
|
||||
def reload_worker_directory
|
||||
if dir = @options[:worker_directory]
|
||||
log "+ Changing to #{dir}"
|
||||
Dir.chdir dir
|
||||
end
|
||||
end
|
||||
|
||||
def stats
|
||||
%Q!{ "workers": #{@workers.size}, "phase": #{@phase}, "booted_workers": #{@workers.count{|w| w.booted?}} }!
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ require 'socket'
|
|||
module Puma
|
||||
class ControlCLI
|
||||
|
||||
COMMANDS = %w{halt restart phased-restart start stats status stop}
|
||||
COMMANDS = %w{halt restart phased-restart start stats status stop reload-worker-directory}
|
||||
|
||||
def is_windows?
|
||||
RUBY_PLATFORM =~ /(win|w)32$/ ? true : false
|
||||
|
@ -201,6 +201,10 @@ module Puma
|
|||
puts "Stats not available via pid only"
|
||||
return
|
||||
|
||||
when "reload-worker-directory"
|
||||
puts "reload-worker-directory not available via pid only"
|
||||
return
|
||||
|
||||
when "phased-restart"
|
||||
Process.kill "SIGUSR1", pid
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue