Passenger 2.2.7 not reading RailsEnv like it used to

218 views
Skip to first unread message

jamieorc

unread,
Nov 30, 2009, 12:42:05 PM11/30/09
to Phusion Passenger Discussions
I've been running several Rails apps with progressive versions of
Passenger for well over a year now. Today I upgraded from 2.2.5 to
2.2.7 and now instead of loading RailsEnv staging (in my apache config
files for each app), "development" is loaded by passenger. I've
reverted to 2.2.5 and my apps load the correct Rails environment
again.

What's changed?

Thanks,

Jamie

Hongli Lai

unread,
Nov 30, 2009, 3:33:40 PM11/30/09
to phusion-passenger
Nothing has changed in that area. Is ENV['RAILS_ENV'] set correctly
for you in 2.2.7?

--
Phusion | The Computer Science Company

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

jamieorc

unread,
Nov 30, 2009, 4:23:54 PM11/30/09
to Phusion Passenger Discussions
Here's the apache conf file that has worked with all previous versions
of Passenger I've used up through 2.2.5. Fails with 2.2.7. This
happened with two different Rails 2.3.4 apps:

<VirtualHost *:80>
ServerName omitted

ServerAlias omitted

DocumentRoot /var/www/apps/omitted/staging-web/current/public

RailsEnv staging

<Directory /var/www/apps/omitted/staging-web/current/public>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

# Redirect old cgi-bin to
RedirectMatch /cgi-bin/* /


RailsAllowModRewrite on
RewriteEngine On

# Rewrite for XTF server
RewriteRule ^/xtf/(.*)$ http://127.0.0.1:8090%{REQUEST_URI} [P]
ProxyPreserveHost On


# Prevent access to .git directories
RewriteRule ^(.*/)?\.git/ - [F,L]
ErrorDocument 403 "Access Forbidden"


# Check for maintenance file and redirect all requests
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /system/maintenance.html [L]


# Deflate
AddOutputFilterByType DEFLATE text/html text/plain text/xml
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# Use Apache cookies, session tracking with mod_usertrack
CookieTracking on
CookieName "httpd_cookie"
CookieDomain .staging.omitted.com
CookieExpires 3600

ErrorLog logs/staging.omitted.com-error_log
CustomLog "|/usr/sbin/cronolog /var/log/httpd/staging.omitted.com-
access_log.%Y-%m" "%{cookie}n %h %l\
%u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
# CustomLog logs/staging.omitted.com-access_log "%{cookie}n %h %l %u
%t \"%r\" %>s %b \"%{Referer}i\"\
\"%{User-Agent}i\""
#combined

</VirtualHost>

Nando

unread,
Dec 4, 2009, 6:41:49 AM12/4/09
to Phusion Passenger Discussions
check if you have a config.ru file in your Rails app and
remove it.
If your app isn't a Rack app should work fine :)

On Nov 30, 7:23 pm, jamieorc <jamie...@gmail.com> wrote:
> Here's the apache conf file that has worked with all previous versions
> of Passenger I've used up through 2.2.5. Fails with 2.2.7. This
> happened with two different Rails 2.3.4 apps:
>
> <VirtualHost *:80>
>   ServerName omitted
>
>     ServerAlias omitted
>
>   DocumentRoot /var/www/apps/omitted/staging-web/current/public
>
>   RailsEnv staging
>
>   <Directory /var/www/apps/omitted/staging-web/current/public>
>     Options FollowSymLinks
>     AllowOverride None
>     Order allow,deny
>     Allow from all
>   </Directory>
>
> # Redirect old cgi-bin to
>   RedirectMatch /cgi-bin/* /
>
>   RailsAllowModRewrite on
>   RewriteEngine On
>
>   # Rewrite for XTF server
>   RewriteRule ^/xtf/(.*)$http://127.0.0.1:8090%{REQUEST_URI} [P]

jamieorc

unread,
Dec 6, 2009, 12:39:10 PM12/6/09
to Phusion Passenger Discussions
Nando, I'm confused. Rails 2.3.* apps are Rack apps and need
config.ru, correct?

Jamie

Anuj Dutta

unread,
Dec 6, 2009, 12:50:55 PM12/6/09
to phusion-...@googlegroups.com


2009/12/6 jamieorc <jami...@gmail.com>
--

You received this message because you are subscribed to the Google Groups "Phusion Passenger Discussions" group.
To post to this group, send email to phusion-...@googlegroups.com.
To unsubscribe from this group, send email to phusion-passen...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/phusion-passenger?hl=en.



Hey Jamie,

What is the error message that you get?

Anuj


--
Anuj DUTTA

jamieorc

unread,
Dec 6, 2009, 1:09:56 PM12/6/09
to Phusion Passenger Discussions
The standard Rails "We're sorry, but something went wrong."

The reason is because it's trying to load the development environment,
not the production or staging environment. There's no database
connection for development.

It should not be loading development, but production.

I just deployed 2.2.7 to a completely different system (Ubuntu on
Slicehost, Standard Ruby instead of CentOS on RailsMachine, Enterprise
Ruby) and encountered the same problem. This project is Rails 2.3.5.
Reverting to Passenger 2.2.4 gets the app up and running again. Which
is to say, it's correctly loading the production environment instead
of the development environment.

The project on Slicehost is a very straight-forward, simple Rails app
I've been running on Passenger for at least a year. The apps I
originally reported are apps I've been running with Passenger for a
client even longer on RailsMachine.

Jamie

On Dec 6, 12:50 pm, Anuj Dutta <dutta.a...@googlemail.com> wrote:
> 2009/12/6 jamieorc <jamie...@gmail.com>
> > phusion-passen...@googlegroups.com<phusion-passenger%2Bunsubscr i...@googlegroups.com>
> > .

jamieorc

unread,
Dec 6, 2009, 1:16:08 PM12/6/09
to Phusion Passenger Discussions
In a nutshell, when I use Passenger 2.2.7, it's always loading the
development environment instead of production or staging (if I've
defined staging to be used).

Jamie

Hongli Lai

unread,
Dec 6, 2009, 2:11:54 PM12/6/09
to phusion-passenger
On Sun, Dec 6, 2009 at 6:39 PM, jamieorc <jami...@gmail.com> wrote:
> Nando, I'm confused. Rails 2.3.* apps are Rack apps and need
> config.ru, correct?

No, they don't. Phusion Passenger makes a strict difference between
Rails apps and Rack apps even though technically Rails apps can be
Rack apps. But if you put a config.ru in there then Phusion Passenger
will treat your Rails app in an entirely different way. For example
you will lose all the Ruby Enterprise Edition copy-on-write savings
and you will also lose all the startup time reduction mechanisms.
It'll also cause RAILS_ENV to be no longer set because Phusion
Passenger only sets RACK_ENV for Rack apps.

jamieorc

unread,
Dec 6, 2009, 2:24:00 PM12/6/09
to Phusion Passenger Discussions
Hongli, that was the problem. I removed config.ru and now the app
works with Passenger 2.2.7.

Thanks,

Jamie

Anuj Dutta

unread,
Dec 6, 2009, 3:04:05 PM12/6/09
to phusion-...@googlegroups.com


2009/12/7 jamieorc <jami...@gmail.com>
--

You received this message because you are subscribed to the Google Groups "Phusion Passenger Discussions" group.
To post to this group, send email to phusion-...@googlegroups.com.
To unsubscribe from this group, send email to phusion-passen...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/phusion-passenger?hl=en.



Out of curiosity, may I ask what benefit do we have by treating Rails apps and Rack apps differently on Passenger?

Anuj

--
Anuj DUTTA

Hongli Lai

unread,
Dec 6, 2009, 3:09:17 PM12/6/09
to phusion-passenger
On Sun, Dec 6, 2009 at 9:04 PM, Anuj Dutta <dutta...@googlemail.com> wrote:
> Out of curiosity, may I ask what benefit do we have by treating Rails apps
> and Rack apps differently on Passenger?

The copy-on-write memory saving stuff depends on it. It works by
preloading Rails and the application code into a process called the
ApplicationSpawner. Then, whenever a Rails worker process is needed,
the ApplicationSpawner forks off a worker process that shares most of
its memory with the ApplicationSpawner process. ApplicationSpawner
also improves startup time by an order of magnitude because it has
already loaded Rails; cold loading Rails can take several seconds.

None of this is possible with Rack because Rack is an abstraction
layer and you don't know what framework is behind it. The
ApplicationSpawner stuff is extremely Rails-specific.

Anuj Dutta

unread,
Dec 6, 2009, 3:18:12 PM12/6/09
to phusion-...@googlegroups.com


2009/12/7 Hongli Lai <hon...@phusion.nl>
--

You received this message because you are subscribed to the Google Groups "Phusion Passenger Discussions" group.
To post to this group, send email to phusion-...@googlegroups.com.
To unsubscribe from this group, send email to phusion-passen...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/phusion-passenger?hl=en.



Thanks. I assume the code is on github. I will have a look.

Cheers.

Anuj


--
Anuj DUTTA

Nando

unread,
Dec 7, 2009, 5:51:38 AM12/7/09
to Phusion Passenger Discussions
good to know that :)
Thanks Hongli Lai

On Dec 6, 5:11 pm, Hongli Lai <hon...@phusion.nl> wrote:
> On Sun, Dec 6, 2009 at 6:39 PM, jamieorc <jamie...@gmail.com> wrote:
> > Nando, I'm confused. Rails 2.3.* apps are Rack apps and need
> > config.ru, correct?
>
> No, they don't. Phusion Passenger makes a strict difference between
> Rails apps and Rack apps even though technically Rails apps can be
> Rack apps. But if you put a config.ru in there then Phusion Passenger
> will treat your Rails app in an entirely different way. For example
> you will lose all the Ruby Enterprise Edition copy-on-write savings
> and you will also lose all the startup time reduction mechanisms.
> It'll also cause RAILS_ENV to be no longer set because Phusion
> Passenger only sets RACK_ENV for Rack apps.
>
> --
> Phusion | The Computer Science Company
>
> Web:http://www.phusion.nl/
> E-mail: i...@phusion.nl
Reply all
Reply to author
Forward
0 new messages