On Sun, Oct 9, 2011 at 15:43, Nokan Emiro <uzleep...@gmail.com> wrote:
> Hi,
>
> Could you please show me the preferred/nicest way
> to run my Camping application as a Rack all?  I like
> doing my work in Rack because it's easy to run my app
> in a standalone webserver, or "mount" it to a path in
> my production environment as a FastCGI app.
>
> require 'rubygems'
> require 'rack'
> app = ...
> Rack::Handler::FastCGI.run app, :Port => nnnn
>
> I use Camping as a proof-of-concept framework, but it's
> time to turn some of my apps into production, and I'm looking
> for the right way to do this, and I think this is to make it run
> as a Rack app.  I've found code snippets on the net but
> none of them worked.  This one is the less wrong one:
>
> require 'rubygems'
> require 'rack'
> require 'camping'
>
> Camping.goes :X
> module X
>     # my Camping app here #
> end
>
> X.create
>
> Rack::Handler::FastCGI.run X, :Port => 8899
>
> I know it's not good.  Basicly my question is:  how to repair this? :)
>
> I have two problems:
>
> 1) X.create makes ugly error messages

Now that you have solved your real problem, let me explain this one too:

X.create is purely a convention so you can write code that will run on
startup inside your application. So you can write this in your
application:

  def X.create
    # run migrations etc.
  end

Then a "proper" Camping server (like your FastCGI-wrapper) will make
sure to invoke X.create. Of course, a proper Camping server must also
take care to handle applications that *don't* define X.create, so that
line should actually look like this:

  # inside the server:
  X.create if X.respond_to? :create
_______________________________________________
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list

Reply via email to