From 571f38c6c9efd776b0704ddba35078c972289de6 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 1 Mar 2009 22:05:44 -0800 Subject: Unlink the pid file explicitly when master exits Relying on at_exit can still means a child might get it if there's any race condition.... --- lib/unicorn.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/unicorn.rb b/lib/unicorn.rb index fa2ebe8..4e09b0c 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -120,7 +120,6 @@ module Unicorn "(or pid=#{path} is stale)" end File.open(path, 'wb') { |fp| fp.syswrite("#{$$}\n") } - at_exit { unlink_pid_safe(path) } end unlink_pid_safe(@pid) if @pid && @pid != path @pid = path @@ -220,6 +219,7 @@ module Unicorn end stop # gracefully shutdown all workers on our way out logger.info "master PID:#{$$} join complete" + unlink_pid_safe(@pid) if @pid end # Terminates all workers, but does not exit master process -- cgit v1.2.3-24-ge0c7