Hi all,

What I do is check the ENV variable ... and I use Passenger Phusion to run
my Rack apps

So ... like this ... install Apache and Passenger Phusion and point
passenger at a rack_apps dir (under the web server root)

Now I have

/var/www/localhost/htdocs <- web server doc root

/var/www/localhost/htdocs/rack_apps/* <- rack_apps

  cd /var/www/localhost/htdocs
and
  camping rack_apps/*/config.ru
runs all my Camping apps in dev mode

or ... to run as a rack app (using passenger) at the end of your
config.ruput this addendum

Camping.goes :MyApp

module MyApp
# blah blah blah
end

case ENV['RACK_ENV']
  when 'development'
    # set a mode var?
    debug "i'm in rack dev mode"
    ENV['MODE'] = 'development'
  when 'production'
    # set a mode var?
    debug "i'm in rack live mode"
    ENV['MODE'] ||= 'production'

    run MyApp # !!!!!! this is the important bit !!!!!

  else
    ENV['MODE'] = nil
end

if __FILE__ == $0
  # this library may be run as a standalone script
  # as in -> ruby rack_apps/___/config.ru
  # dunno why you'd want to do that but anyway

  # set a mode var?
  debug "i'm in standalone mode"
  ENV['MODE']='standalone'
end

I don't know, maybe this is all obvious but it took me a little while to
figure it out cuz I'm a bit slow about these things.

Regards,
    Anthony

On Sun, Oct 9, 2011 at 4:43 PM, 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
> 2) if I comment out the X.create line, it seems to work, but does
> not really do.  It listens for connections on 8899, but it halt on
> the first fcgi connection from the webserver.
>
> thx,
> uzlee
>
> _______________________________________________
> 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