passenger 2.2.7 uses config.ru but starts in development environment

169 views
Skip to first unread message

Gennady Chertanov

unread,
Nov 23, 2009, 7:33:12 AM11/23/09
to Phusion Passenger Discussions
Hi.

Today i updated passenger to new 2.2.7 version and my app started to
work incorrectly, because it launched in development environment.

I tried to set "RailsEnv production", "RackEnv production" at my
httpd.conf, but this dont work.

So, maybe somenthing wrong with my config.ru?

#!/usr/bin/env rackup -p3000
require "config/environment"

use Rails::Rack::LogTailer
use Rack::AssetPath # <- my own middleware
use Rails::Rack::Static
run ActionController::Dispatcher.new

What is wrong? Where can i read about customizing config.ru for
production environments?

Thank you

Hongli Lai

unread,
Nov 23, 2009, 8:13:59 AM11/23/09
to phusion-...@googlegroups.com
Phusion Passenger sets RACK_ENV, not RAILS_ENV, for Rack apps.

--
Phusion | The Computer Science Company

Web: http://www.phusion.nl/
E-mail: in...@phusion.nl
Chamber of commerce no: 08173483 (The Netherlands)

Gennady Chertanov

unread,
Nov 23, 2009, 9:36:48 AM11/23/09
to Phusion Passenger Discussions
Okay, i can define RAILS_ENV from RACK_ENV. Thank you :-)

But main part of the question was about "passenger & rack best
practices".

For example, i have 1 middleware, which i want to use throughout
config.ru. What is the most common config.ru file for rails project
that allow me to do it in development and in production via Phusion
Passenger?

Thank you again ;-)

On 23 ноя, 16:13, Hongli Lai <hon...@phusion.nl> wrote:
> On Mon, Nov 23, 2009 at 1:33 PM, Gennady Chertanov <alx....@gmail.com> wrote:
> > Hi.
>
> > Today i updated passenger to new 2.2.7 version and my app started to
> > work incorrectly, because it launched in development environment.
>
> > I tried to set "RailsEnv production", "RackEnv production" at my
> > httpd.conf, but this dont work.
>
> > So, maybe somenthing wrong with my config.ru?
>
> > #!/usr/bin/env rackup -p3000
> > require "config/environment"
>
> > use Rails::Rack::LogTailer
> > use Rack::AssetPath # <- my own middleware
> > use Rails::Rack::Static
> > run ActionController::Dispatcher.new
>
> > What is wrong? Where can i read about customizing config.ru for
> > production environments?
>
> Phusion Passenger sets RACK_ENV, not RAILS_ENV, for Rack apps.
>
> --
> Phusion | The Computer Science Company
>
> Web:http://www.phusion.nl/
> E-mail: i...@phusion.nl

Hongli Lai

unread,
Nov 23, 2009, 10:46:24 AM11/23/09
to phusion-...@googlegroups.com
On Mon, Nov 23, 2009 at 3:36 PM, Gennady Chertanov <alx...@gmail.com> wrote:
> Okay, i can define RAILS_ENV from RACK_ENV. Thank you :-)
>
> But main part of the question was about "passenger & rack best
> practices".
>
> For example, i have 1 middleware, which i want to use throughout
> config.ru. What is the most common config.ru file for rails project
> that allow me to do it in development and in production via Phusion
> Passenger?

There is no common config.ru because using config.ru for Rails is not
common. But your config.ru looks correct.

--
Phusion | The Computer Science Company

Web: http://www.phusion.nl/
E-mail: in...@phusion.nl

Gennady Chertanov

unread,
Nov 24, 2009, 4:32:37 AM11/24/09
to Phusion Passenger Discussions
Thank you :-)

However, i understood, that i want to use my config.ru only on
development environment (i use it for rewrites only). Is there any way
to force Phusion Passenger not using it in production?

The problem is when i set up rewrite middleware in development.rb,
every request (even if it will be rewrited) will restart Rails. When i
use it in config.ru Rack rewrites requests before passing them to
Rails.

I know that checking existance of config.ru to enable Rack is very
clever, but i think someone need control on this :-)

Thank you very much for your answers. Becoming your fan :-)

On 23 ноя, 18:46, Hongli Lai <hon...@phusion.nl> wrote:
> On Mon, Nov 23, 2009 at 3:36 PM, Gennady Chertanov <alx....@gmail.com> wrote:
> > Okay, i can define RAILS_ENV from RACK_ENV. Thank you :-)
>
> > But main part of the question was about "passenger & rack best
> > practices".
>
> > For example, i have 1 middleware, which i want to use throughout
> > config.ru. What is the most common config.ru file for rails project
> > that allow me to do it in development and in production via Phusion
> > Passenger?
>
> There is no common config.ru because using config.ru for Rails is not
> common. But your config.ru looks correct.
>
> --
> Phusion | The Computer Science Company
>
> Web:http://www.phusion.nl/
> E-mail: i...@phusion.nl

Hongli Lai

unread,
Nov 24, 2009, 4:58:00 AM11/24/09
to phusion-...@googlegroups.com
On Tue, Nov 24, 2009 at 10:32 AM, Gennady Chertanov <alx...@gmail.com> wrote:
> Thank you :-)
>
> However, i understood, that i want to use my config.ru only on
> development environment (i use it for rewrites only). Is there any way
> to force Phusion Passenger not using it in production?

Yes: delete config.ru on your production server.

> The problem is when i set up rewrite middleware in development.rb,
> every request (even if it will be rewrited) will restart Rails. When i
> use it in config.ru Rack rewrites requests before passing them to
> Rails.
>
> I know that checking existance of config.ru to enable Rack is very
> clever, but i think someone need control on this :-)
>
> Thank you very much for your answers. Becoming your fan :-)

I believe Rails allows you to change the Rack middleware chain inside
environment.rb.

--
Phusion | The Computer Science Company

Web: http://www.phusion.nl/
E-mail: in...@phusion.nl
Reply all
Reply to author
Forward
0 new messages