def before_handling_requests(forked, options)
      if forked
        # Reseed pseudo-random number generator for security reasons.
        srand
      end

      if options["process_title"] && !options["process_title"].empty?
        $0 = options["process_title"] + ": " + options["app_group_name"]
      end

      # If we were forked from a preloader process then clear or
      # re-establish ActiveRecord database connections. This prevents
      # child processes from concurrently accessing the same
      # database connection handles.
      if forked && defined?(ActiveRecord::Base)
        if ActiveRecord::Base.respond_to?(:clear_all_connections!)
          ActiveRecord::Base.clear_all_connections!
        elsif ActiveRecord::Base.respond_to?(:clear_active_connections!)
          ActiveRecord::Base.clear_active_connections!
        elsif ActiveRecord::Base.respond_to?(:connected?) &&
              ActiveRecord::Base.connected?
          ActiveRecord::Base.establish_connection
        end
      end

      # Fire off events.
      PhusionPassenger.call_event(:starting_worker_process, forked)
      if options["pool_account_username"] && options["pool_account_password_base64"]
        password = options["pool_account_password_base64"].unpack('m').first
        PhusionPassenger.call_event(:credentials,
          options["pool_account_username"], password)
      else
        PhusionPassenger.call_event(:credentials, nil, nil)
      end
    end
def before_handling_requests(forked, options)
      if forked
        # Reseed pseudo-random number generator for security reasons.
        srand
      end

      if options["process_title"] && !options["process_title"].empty?
        $0 = options["process_title"] + ": " + options["app_group_name"]
      end

      # If we were forked from a preloader process then clear or
      # re-establish ActiveRecord database connections. This prevents
      # child processes from concurrently accessing the same
      # database connection handles.
      if forked && defined?(ActiveRecord::Base)
        if ActiveRecord::Base.respond_to?(:clear_all_connections!)
          ActiveRecord::Base.clear_all_connections!
        elsif ActiveRecord::Base.respond_to?(:clear_active_connections!)
          ActiveRecord::Base.clear_active_connections!
        elsif ActiveRecord::Base.respond_to?(:connected?) &&
              ActiveRecord::Base.connected?
          ActiveRecord::Base.establish_connection
        end
      end

      # Fire off events.
      PhusionPassenger.call_event(:starting_worker_process, forked)
      if options["pool_account_username"] && options["pool_account_password_base64"]
        password = options["pool_account_password_base64"].unpack('m').first
        PhusionPassenger.call_event(:credentials,
          options["pool_account_username"], password)
      else
        PhusionPassenger.call_event(:credentials, nil, nil)
      end
    end
To be called before the request handler main loop is entered, but after the app
 startup file has been loaded. This function will fire off necessary events
 and perform necessary preparation tasks.

 +forked+ indicates whether the current worker process is forked off from
 an ApplicationSpawner that has preloaded the app code.
 +options+ are the spawn options that were passed.