From 29c6af908c2bd1109be175c34b89c45c8cc2f60b Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 18 Mar 2009 01:59:17 -0700 Subject: gracefully die if working dir is invalid at fork In nearly every app, if the current working directory disappears, the app becomes broken, sometimes subtly. It can be especially broken when preload_app is false (the default). So just shut ourselves down to spare ourselves the wasted CPU cycles on a dead app. As a (hopefully) pleasant side effect, this allows configurations with preload_app==false (the default) to do application code reloads via SIGHUP (in addition to unicorn config reloads). --- lib/unicorn/configurator.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/unicorn') diff --git a/lib/unicorn/configurator.rb b/lib/unicorn/configurator.rb index dd9ae3b..ae74c2b 100644 --- a/lib/unicorn/configurator.rb +++ b/lib/unicorn/configurator.rb @@ -194,6 +194,10 @@ module Unicorn # properly close/reopen sockets. Files opened for logging do not # have to be reopened as (unbuffered-in-userspace) files opened with # the File::APPEND flag are written to atomically on UNIX. + # + # In addition to reloading the unicorn-specific config settings, + # SIGHUP will reload application code in the working + # directory/symlink when workers are gracefully restarted. def preload_app(bool) case bool when TrueClass, FalseClass -- cgit v1.2.3-24-ge0c7