RailsEnv per virtualhost

10 views
Skip to first unread message

Tim Uckun

unread,
Nov 12, 2008, 6:56:58 PM11/12/08
to phusion-...@googlegroups.com
I have three virtual hosts. Two of them have been running as
production. I want to add a third one and run it as staging so I
removed the RailsEnv production from the module conf and added it to
each of the virtual host directives.

What happens is that phusion is using the last railsenv it processes
for all the virtual hosts (like setting it globally).

I am using passenger 2.03 on ubuntu and apache 2.2.8

Steffen

unread,
Nov 12, 2008, 7:29:05 PM11/12/08
to Phusion Passenger Discussions
Hey Tim,

I posted the same question a few weeks ago, but couldn't find a better
solution than have to restart the apache everytime I switch the env.
Here's my thread:
http://groups.google.com/group/phusion-passenger/browse_thread/thread/1e36a05a2bcb2d5a/0ebad6293743cae2?lnk=gst&q=railsenv+vhost#0ebad6293743cae2

Maybe this time someone has a better idea?

Cheers,
Steffen

Tim Uckun

unread,
Nov 12, 2008, 7:52:53 PM11/12/08
to phusion-...@googlegroups.com
>
> I posted the same question a few weeks ago, but couldn't find a better
> solution than have to restart the apache everytime I switch the env.
> Here's my thread:
> http://groups.google.com/group/phusion-passenger/browse_thread/thread/1e36a05a2bcb2d5a/0ebad6293743cae2?lnk=gst&q=railsenv+vhost#0ebad6293743cae2
>

I keep seeing references to the fact that railsenv is supposed to work
on a per virtualhost. The documentation says it's supposed to work on
a per virtualhost basis.

Perhaps there is some other setting that needs to be tweaked in order
to make it work.

In my case I can't use the reboot trick because all sites have to be
up all the time.

Levi Cook

unread,
Nov 12, 2008, 10:55:33 PM11/12/08
to phusion-...@googlegroups.com
A couple "out of band" options...

1) Run a second instance of apache on a separate port?
2) Set RAILS_ENV w/in your environment.rb...you can do it conditionally by figuring out what host and/or directory you're in.

Totally missing the specifics of your question, but it might get you going.

Steffen

unread,
Nov 13, 2008, 12:06:57 AM11/13/08
to Phusion Passenger Discussions
Tim,
yes, it's supposed to work on per virtualhost, but I guess the problem
(or bug) is, that both of your virtual hosts point to the same app. If
you check passenger-memory-stats, you see that the spawner of
passenger differentiates the apps by their app root. So two vhosts,
two different app roots, and each a different railsenv should work
fine, I guess. I know, it's a pity that it's not working as expected.

Levi,
what do you mean with a second instance of apache? Do you mean a
second apache installation?
I know you can tell apache to listen on a different/extra port and
define an extra vhost for that, but at the end would just be another
vhost, too. But would be interesting to see, if the behaviour changes.
I might give that a try.

Regards,
Steffen

On 12 Nov., 23:55, "Levi Cook" <levic...@gmail.com> wrote:
> A couple "out of band" options...
>
> 1) Run a second instance of apache on a separate port?
> 2) Set RAILS_ENV w/in your environment.rb...you can do it conditionally by
> figuring out what host and/or directory you're in.
>
> Totally missing the specifics of your question, but it might get you going.
>
> On Wed, Nov 12, 2008 at 6:29 PM, Steffen <steffen.hil...@gmail.com> wrote:
>
> > Hey Tim,
>
> > I posted the same question a few weeks ago, but couldn't find a better
> > solution than have to restart the apache everytime I switch the env.
> > Here's my thread:
>
> >http://groups.google.com/group/phusion-passenger/browse_thread/thread...

Tim Uckun

unread,
Nov 16, 2008, 7:49:32 PM11/16/08
to phusion-...@googlegroups.com
On Thu, Nov 13, 2008 at 6:06 PM, Steffen <steffen...@gmail.com> wrote:
>
> Tim,
> yes, it's supposed to work on per virtualhost, but I guess the problem
> (or bug) is, that both of your virtual hosts point to the same app. If
> you check passenger-memory-stats, you see that the spawner of
> passenger differentiates the apps by their app root. So two vhosts,
> two different app roots, and each a different railsenv should work
> fine, I guess. I know, it's a pity that it's not working as expected.
>

Actually that's not the case. In my case they are different app roots
too. One is in /var/www/application and other in
/var/www/application_staging.

So in my case it's two different roots, two different vhosts two
different (supposedly) environments.

BTW I did an ugly hacky workaround with capistrano. Here is what I did.

task :after_update_code, :roles => :app do
run "rm -rf #{release_path}/public/.htaccess"
run %Q( sed -i "s/#SED_ME/RAILS_ENV = 'staging'/"
#{release_path}/config/environment.rb )
end

As you can see I call out to sed to replace the #SED_ME comment with
the RAILS_ENV call.

Tim Uckun

unread,
Dec 3, 2008, 4:37:16 AM12/3/08
to phusion-...@googlegroups.com
I am going to bump this thread.

Is this problem fixed with the new version of phusion? Can we specify
a different rails env for different applications?

Hongli Lai

unread,
Dec 3, 2008, 4:55:30 AM12/3/08
to phusion-...@googlegroups.com

RailsEnv per virtual host has been supported since June 2008 with
version 1.9.0.

--
Phusion | The Computer Science Company

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

Reply all
Reply to author
Forward
0 new messages