Skip to content

Commit

Permalink
Start the server if another user has a PID matching our stale pidfile.
Browse files Browse the repository at this point in the history
If unicorn doesn't get terminated cleanly (for example if the machine
has its power interrupted) and the pid in the pidfile gets used by
another process, the current unicorn code will exit and not start a
server. This tiny patch fixes that behaviour.

Acked-by: Eric Wong <normalperson@yhbt.net>
  • Loading branch information
bleach authored and Eric Wong committed Feb 29, 2012
1 parent b6a154e commit 2ce5795
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/unicorn/http_server.rb
Expand Up @@ -656,7 +656,7 @@ def valid_pid?(path)
wpid <= 0 and return
Process.kill(0, wpid)
wpid
rescue Errno::ESRCH, Errno::ENOENT
rescue Errno::ESRCH, Errno::ENOENT, Errno::EPERM
# don't unlink stale pid files, racy without non-portable locking...
end

Expand Down

0 comments on commit 2ce5795

Please sign in to comment.