lib/rack/unreloader.rb
def call(env)
      if @cooldown && Time.now > @last + @cooldown
        begin
          MUTEX.synchronize{reload!}
        rescue StandardError, ScriptError => e
          raise unless @handle_reload_errors
          content = "#{e.class}: #{e}\n#{e.backtrace.join("\n")}"
          return [500, {'Content-Type' => 'text/plain', 'Content-Length' => content.bytesize.to_s}, [content]]
        end
        @last = Time.now
      end
      @app_block.call.call(env)
    end
def call(env)
      if @cooldown && Time.now > @last + @cooldown
        begin
          MUTEX.synchronize{reload!}
        rescue StandardError, ScriptError => e
          raise unless @handle_reload_errors
          content = "#{e.class}: #{e}\n#{e.backtrace.join("\n")}"
          return [500, {'Content-Type' => 'text/plain', 'Content-Length' => content.bytesize.to_s}, [content]]
        end
        @last = Time.now
      end
      @app_block.call.call(env)
    end
Setup the reloader. Options:

 :cooldown :: The number of seconds to wait between checks for changed files.
              Defaults to 1.  Set to nil/false to not check for changed files.
 :reload :: Set to false to not setup a reloader, and just have require work
            directly.  Should be set to false in production mode.
 :logger :: A Logger instance which will log information related to reloading.
 :subclasses :: A string or array of strings of class names that should be unloaded.
                Any classes that are not subclasses of these classes will not be
                unloaded.  This also handles modules, but module names given must
                match exactly, since modules don't have superclasses.
 If the cooldown time has been passed, reload any application files that have changed.
 Call the app with the environment.