mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Add status to pumactl with pidfile (#1824)
ref https://github.com/puma/puma/pull/1767
This commit is contained in:
parent
e68a462679
commit
5a2291ef1b
3 changed files with 25 additions and 6 deletions
|
@ -206,6 +206,16 @@ module Puma
|
|||
when "phased-restart"
|
||||
Process.kill "SIGUSR1", @pid
|
||||
|
||||
when "status"
|
||||
begin
|
||||
Process.kill 0, @pid
|
||||
puts "Puma is started"
|
||||
rescue Errno::ESRCH
|
||||
raise "Puma is not running"
|
||||
end
|
||||
|
||||
return
|
||||
|
||||
else
|
||||
return
|
||||
end
|
||||
|
|
|
@ -2,6 +2,8 @@ system "ruby -rrubygems -Ilib bin/pumactl -F test/shell/t2_conf.rb start"
|
|||
sleep 5
|
||||
system "curl http://localhost:10103/"
|
||||
|
||||
out=`ruby -rrubygems -Ilib bin/pumactl -F test/shell/t2_conf.rb status`
|
||||
|
||||
system "ruby -rrubygems -Ilib bin/pumactl -F test/shell/t2_conf.rb stop"
|
||||
|
||||
sleep 1
|
||||
|
@ -10,7 +12,7 @@ log = File.read("t2-stdout")
|
|||
|
||||
File.unlink "t2-stdout" if File.file? "t2-stdout"
|
||||
|
||||
if log =~ %r(GET / HTTP/1\.1) && !File.file?("t2-pid")
|
||||
if log =~ %r(GET / HTTP/1\.1) && !File.file?("t2-pid") && out == "Puma is started\n"
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
|
|
|
@ -39,7 +39,7 @@ class TestPumaControlCli < Minitest::Test
|
|||
assert_equal 'none', control_cli.instance_variable_get("@control_auth_token")
|
||||
end
|
||||
|
||||
def test_control_url
|
||||
def test_control_url_and_status
|
||||
host = "127.0.0.1"
|
||||
port = find_open_port
|
||||
url = "tcp://#{host}:#{port}/"
|
||||
|
@ -64,11 +64,18 @@ class TestPumaControlCli < Minitest::Test
|
|||
assert_match "200 OK", body
|
||||
assert_match "embedded app", body
|
||||
|
||||
status_cmd = Puma::ControlCLI.new(opts + ["status"])
|
||||
out, _ = capture_subprocess_io do
|
||||
status_cmd.run
|
||||
end
|
||||
assert_match "Puma is started\n", out
|
||||
|
||||
shutdown_cmd = Puma::ControlCLI.new(opts + ["halt"])
|
||||
shutdown_cmd.run
|
||||
out, _ = capture_subprocess_io do
|
||||
shutdown_cmd.run
|
||||
end
|
||||
assert_match "Command halt sent success\n", out
|
||||
|
||||
# TODO: assert something about the stop command
|
||||
|
||||
t.join
|
||||
assert_kind_of Thread, t.join, "server didn't stop"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue