diff --git a/lib/puma/cli.rb b/lib/puma/cli.rb index 7edc9364..d208f315 100644 --- a/lib/puma/cli.rb +++ b/lib/puma/cli.rb @@ -242,6 +242,12 @@ module Puma ENV['RACK_ENV'] = @options[:environment] || ENV['RACK_ENV'] || 'development' end + def delete_pidfile + if path = @options[:pidfile] + File.unlink path + end + end + def write_state require 'yaml' @@ -274,6 +280,7 @@ module Puma def graceful_stop(server) log " - Gracefully stopping, waiting for requests to finish" server.stop(true) + delete_pidfile log " - Goodbye!" end @@ -456,6 +463,7 @@ module Puma def stop @server.stop(true) if @server + delete_pidfile end end end diff --git a/test/test_cli.rb b/test/test_cli.rb index 2c5cb77d..09ed9b1d 100644 --- a/test/test_cli.rb +++ b/test/test_cli.rb @@ -27,6 +27,9 @@ class TestCLI < Test::Unit::TestCase cli.write_pid assert_equal File.read(@tmp_path).strip.to_i, Process.pid + + cli.stop + assert !File.exist?(@tmp_path), "Pid file shouldn't exist anymore" end def test_control_for_tcp