From 27ae210dde9228cfa96ea6b0f3a7e4047d3f70a4 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 2 May 2014 23:15:58 +0000 Subject: http_server: handle premature grandparent death When daemonizing, it is possible for the grandparent to be terminated by another process before the master can notify it. Do not abort the master in this case. This may fix the following issue: https://github.com/kostya/eye/issues/49 (which I was notified of privately via email) --- lib/unicorn/http_server.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/unicorn/http_server.rb b/lib/unicorn/http_server.rb index 21cb9a1..a0ca302 100644 --- a/lib/unicorn/http_server.rb +++ b/lib/unicorn/http_server.rb @@ -272,7 +272,11 @@ class Unicorn::HttpServer proc_name 'master' logger.info "master process ready" # test_exec.rb relies on this message if @ready_pipe - @ready_pipe.syswrite($$.to_s) + begin + @ready_pipe.syswrite($$.to_s) + rescue => e + logger.warn("grandparent died too soon?: #{e.message} (#{e.class})") + end @ready_pipe = @ready_pipe.close rescue nil end begin -- cgit v1.2.3-24-ge0c7