New version of code that makes kill -USR1 work corrently at DH.
if ENV["RAILS_ENV"] == "production"
ENV['GEM_PATH']='/home/jonsmirl/gems'
class MyRailsFCGIHandler < RailsFCGIHandler
def process!(provider = FCGI)
# Make a note of $" so we can safely reload this instance.
mark!
run_gc! if gc_request_period
usr1 = trap("USR1", "DEFAULT")
provider.each_cgi do |cgi|
trap("USR1", usr1)
process_request(cgi)
case when_ready
when :reload
reload!
when :restart
close_connection(cgi)
restart!
when :exit
close_connection(cgi)
break
end
gc_countdown
trap("USR1", "DEFAULT")
end
GC.enable
dispatcher_log :info, "terminated gracefully"
rescue SystemExit => exit_error
dispatcher_log :info, "terminated by explicit exit"
rescue Object => fcgi_error
# retry on errors that would otherwise have terminated the FCGI process,
# but only if they occur more than 10 seconds apart.
if !(SignalException === fcgi_error) && Time.now - @last_error_on > 10
@last_error_on = Time.now
dispatcher_error(fcgi_error, "almost killed by this error")
retry
else
#dispatcher_error(fcgi_error, "killed by this error")
end
end
def exit_now_handler(signal)
dispatcher_log :info, "ignoring request to terminate immediately"
end
end
MyRailsFCGIHandler.process! nil, 50
else
RailsFCGIHandler.process! nil, 50
end