mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Add -p option to pumactl
This commit is contained in:
parent
dd494def4e
commit
9300930295
1 changed files with 28 additions and 12 deletions
|
@ -20,7 +20,7 @@ module Puma
|
||||||
@options = {}
|
@options = {}
|
||||||
|
|
||||||
opts = OptionParser.new do |o|
|
opts = OptionParser.new do |o|
|
||||||
o.banner = "Usage: pumactl (-S status_file | -C url -T token) (#{COMMANDS.join("|")})"
|
o.banner = "Usage: pumactl (-p PID | -P pidfile | -S status_file | -C url -T token) (#{COMMANDS.join("|")})"
|
||||||
|
|
||||||
o.on "-S", "--state PATH", "Where the state file to use is" do |arg|
|
o.on "-S", "--state PATH", "Where the state file to use is" do |arg|
|
||||||
@options[:status_path] = arg
|
@options[:status_path] = arg
|
||||||
|
@ -34,6 +34,10 @@ module Puma
|
||||||
@options[:pid_file] = arg
|
@options[:pid_file] = arg
|
||||||
end
|
end
|
||||||
|
|
||||||
|
o.on "-p", "--pid PID", "Pid" do |arg|
|
||||||
|
@options[:pid] = arg.to_i
|
||||||
|
end
|
||||||
|
|
||||||
o.on "-C", "--control-url URL", "The bind url to use for the control server" do |arg|
|
o.on "-C", "--control-url URL", "The bind url to use for the control server" do |arg|
|
||||||
@options[:control_url] = arg
|
@options[:control_url] = arg
|
||||||
end
|
end
|
||||||
|
@ -115,13 +119,13 @@ module Puma
|
||||||
|
|
||||||
# create server object by scheme
|
# create server object by scheme
|
||||||
@server = case uri.scheme
|
@server = case uri.scheme
|
||||||
when "tcp"
|
when "tcp"
|
||||||
TCPSocket.new uri.host, uri.port
|
TCPSocket.new uri.host, uri.port
|
||||||
when "unix"
|
when "unix"
|
||||||
UNIXSocket.new "#{uri.host}#{uri.path}"
|
UNIXSocket.new "#{uri.host}#{uri.path}"
|
||||||
else
|
else
|
||||||
raise "Invalid scheme: #{uri.scheme}"
|
raise "Invalid scheme: #{uri.scheme}"
|
||||||
end
|
end
|
||||||
|
|
||||||
if @options[:command] == "status"
|
if @options[:command] == "status"
|
||||||
message "Puma is started"
|
message "Puma is started"
|
||||||
|
@ -151,17 +155,29 @@ module Puma
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_signal
|
def send_signal
|
||||||
Process.getpgid(@options[:pid])
|
unless pid = @options[:pid]
|
||||||
|
raise "Neither pid nor control url available"
|
||||||
|
end
|
||||||
|
|
||||||
|
begin
|
||||||
|
Process.getpgid pid
|
||||||
|
rescue SystemCallError
|
||||||
|
raise "No pid '#{pid}' found"
|
||||||
|
end
|
||||||
|
|
||||||
case @options[:command]
|
case @options[:command]
|
||||||
when "restart"
|
when "restart"
|
||||||
Process.kill("SIGUSR2", @options[:pid])
|
Process.kill "SIGUSR2", pid
|
||||||
|
|
||||||
when "halt"
|
when "halt"
|
||||||
Process.kill("QUIT", @options[:pid])
|
Process.kill "QUIT", pid
|
||||||
|
|
||||||
when "stop"
|
when "stop"
|
||||||
Process.kill("SIGTERM", @options[:pid])
|
Process.kill "SIGTERM", pid
|
||||||
|
|
||||||
|
when "stats"
|
||||||
|
puts "Stats not available via pid only"
|
||||||
|
return
|
||||||
|
|
||||||
else
|
else
|
||||||
message "Puma is started"
|
message "Puma is started"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue