¡Holá Señor Gómez!

First of all: *Never* use the reloader in production. It's sloooooow!
And because config.ru is mostly used for production, the reloader
isn't enabled there.

Why do you want to use the reloader in config.ru instead of
bin/camping by the way? If you want custom middlewares, you can always
do it like this:

    module App
      user Middleware
    end

And you can change the server it uses by `camping -s thin`.

Anyway, if you want to use Camping::Reloader, you can do something like this:

    require 'camping'
    require 'camping/reloader'

    reloader = Camping::Reloader.new('hello.rb')
    reloader.on_reload do |app|
      app.create if app.respond_to?(:create)
    end

    app = proc do |env|
      # Reload (if needed) at every request:
      reloader.reload!

      # Returns a hash of the apps:
      apps = reloader.apps

      # Get the first app:
      apps.values.first.call(env)
      # If you have several apps, you probably want to
      # mount them on different paths instead.
    end

    run app

If you're on *nix you can also use Shotgun (http://github.com/rtomayko/shotgun):

    require 'camping'

    Shotgun.after_fork do
      Camping::Apps.each do |app|
        app.create if app.respond_to?(:create)
      end
    end

    require 'hello'
    run Hello

And run the app with: `shotgun config.ru`.

Shotgun spawns your app in each own process at *every* request, so
it's like it's automatically starting and stopping a server between
each request. This means that it's slower, but more "correct".
Camping::Reloader keeps everything in the same process, and uses some
Ruby magic to automatically remove objects and load files again. It
work 90% of the times, but is faster (it only reloads when needed) and
it also works on Windows.

Good luck!

// Magnus Holm


2010/8/1 Omar Gómez <omar.go...@gmail.com>:
> Dear Camping ninjas,
>
> I've been using Camping via bin/camping and reloading works as expected OK.
>
> What I have not been able to do is to correctly setup a Camping app
> with reloading support in a standard config.ru rack app.
>
> Thanks for your attention
>
> --Omar Gómez
>
> --
> Follow me at:
> Twitter: http://twitter.com/omargomez
> Buzz: http://www.google.com/profiles/108165850309051561506#buzz
> _______________________________________________
> Camping-list mailing list
> Camping-list@rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list
>
_______________________________________________
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list

Reply via email to