Permalink
Browse files

Delete pidfile when stopping the server

Closes #75
  • Loading branch information...
spastorino authored and evanphx committed Jul 19, 2012
1 parent 55a4753 commit e289c414935eaab3021238becd82bb7f5445a865
Showing with 11 additions and 0 deletions.
  1. +8 −0 lib/puma/cli.rb
  2. +3 −0 test/test_cli.rb
View
@@ -242,6 +242,12 @@ def set_rack_environment
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 @@ def parse_options
def graceful_stop(server)
log " - Gracefully stopping, waiting for requests to finish"
server.stop(true)
+ delete_pidfile
log " - Goodbye!"
end
@@ -456,6 +463,7 @@ def run
def stop
@server.stop(true) if @server
+ delete_pidfile
end
end
end
View
@@ -27,6 +27,9 @@ def test_pid_file
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

0 comments on commit e289c41

Please sign in to comment.