Graham Bleach
2012-Feb-29 14:34 UTC
[PATCH] Start the server if another user has a PID matching our stale pidfile.
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. --- lib/unicorn/http_server.rb | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/lib/unicorn/http_server.rb b/lib/unicorn/http_server.rb index 7d2c623..0c2af5d 100644 --- a/lib/unicorn/http_server.rb +++ b/lib/unicorn/http_server.rb @@ -656,7 +656,7 @@ class Unicorn::HttpServer 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 -- 1.7.5.4
Eric Wong
2012-Feb-29 17:25 UTC
[PATCH] Start the server if another user has a PID matching our stale pidfile.
Graham Bleach <graham at darkskills.org.uk> wrote:> 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.Thanks! Acked-by: Eric Wong <normalperson at yhbt.net> and pushed to master on git://bogomips.org/unicorn.git
Eric Wong
2012-Mar-20 20:10 UTC
[PATCH] Start the server if another user has a PID matching our stale pidfile.
Eric Wong <normalperson at yhbt.net> wrote:> Graham Bleach <graham at darkskills.org.uk> wrote: > > 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. > > Thanks! Acked-by: Eric Wong <normalperson at yhbt.net> > > and pushed to master on git://bogomips.org/unicorn.gitBtw, I also pushed this to be a little more informative:>From d0e7d8d770275654024887a05d9e986589ba358c Mon Sep 17 00:00:00 2001From: Eric Wong <normalperson at yhbt.net> Date: Tue, 20 Mar 2012 20:05:59 +0000 Subject: [PATCH] log EPERM errors from invalid pid files In some cases, EPERM may indicate a real configuration problem, but it can also just mean the pid file is stale. --- lib/unicorn/http_server.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/unicorn/http_server.rb b/lib/unicorn/http_server.rb index 0c2af5d..ede6264 100644 --- a/lib/unicorn/http_server.rb +++ b/lib/unicorn/http_server.rb @@ -656,7 +656,10 @@ class Unicorn::HttpServer wpid <= 0 and return Process.kill(0, wpid) wpid - rescue Errno::ESRCH, Errno::ENOENT, Errno::EPERM + rescue Errno::EPERM + logger.info "pid=#{path} possibly stale, got EPERM signalling PID:#{wpid}" + nil + rescue Errno::ESRCH, Errno::ENOENT # don''t unlink stale pid files, racy without non-portable locking... end --
Maybe Matching Threads
- [PATCH] rework master-to-worker signaling to use a pipe
- [PATCH] replace fchmod()-based heartbeat with raindrops
- app error: Socket is not connected (Errno::ENOTCONN)
- [PATCH] construct listener_fds Hash in 1.8 compatible way
- Ruby 2.0 Bad file descriptor (Errno::EBADF)