Rails-optimized dispatch.fcgi

28 May 2006

After seeing Dreamhost killoff my fastcgi processes I’ve modified my dispatch.fcgi file in accordance with the suggestion on the dreamhost wiki. This is fully functional and you can (probably) just copy and past straight into your dispatch.fcgi file. The contents of the file are mostly just comments anyway, so this significantly simplified my dispatch file. Enough ado, here’s the code:

    require File.dirname(__FILE__) + "/../config/environment"
    require 'fcgi_handler'

    class RailsFCGIHandler
      def fix_handler(signal)
        dispatcher_log :info, "asked to terminate immediately"
        dispatcher_log :info, "fix handler working its magic!"
      alias_method :exit_now_handler, :fix_handler

    RailsFCGIHandler.process! nil, 10
  • Dave said: So what does this 'class RailsFCGIHandler' actually DO? simply restart the handler when the shared host's server asks you to shutdown FCGI? so that it is persistantly turned on until it has been used 10 times?

Please if you found this post helpful or have questions.