# Mongrel & multiple config files

**URL:** <https://www.ruby-forum.com/t/mongrel-multiple-config-files/106947>\
**Category:** Deployment\
**Created:** [June 15, 2007, 3:54pm UTC](https://www.ruby-forum.com/t/mongrel-multiple-config-files/106947 "2007-06-15T15:54:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrislo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/5e9695/32.png) [@chrislo](https://www.ruby-forum.com/u/chrislo)\
**Post date:** [June 15, 2007, 3:54pm UTC](https://www.ruby-forum.com/t/mongrel-multiple-config-files/106947/1 "2007-06-15T15:54:45Z")

</div>

I’m deploying a rails app to separate production and staging  
environments using Capistrano. They’re basically running as two apps on  
the same machine, so I want to make them available on different ports,  
and may also want to have different numbers of mongrels in the clusters.

My plan was to build a config file name based on the RAILS\_ENV setting -  
something like …/config/mongrel/staging.yml or  
…/config/mongrel/production.yml and then set :mongrel\_conf in the  
deploy.rb so that the standard deployment recipes would pick it up. The  
effect of that would be that they would run:

mongrel\_rails cluster::start -C …/config/mongrel/staging.yml

When I tried it it seemed to make no difference at all which config file  
I specified, it would always try and start 2 mongrels on ports 3000 and  
3001.

I tried running the mongrel\_rails command on the server by hand and  
exactly the same thing happened. Am I barking up the wrong tree?  
mongrel\_rails cluster::start -h seems to imply that this should work:

Usage: mongrel\_rails [options]  
-C, --config PATH Path to cluster configuration file  
-v, --verbose Print all called commands and  
output.  
-h, --help Show this message  
–version Show version

Target platform is Ubuntu 7.04/Feisty, Mongrel 1.0.1, Ruby 1.8.5

-Chrisl

---

<div class="post-metadata">

**Author:** ![chrislo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/5e9695/32.png) [@chrislo](https://www.ruby-forum.com/u/chrislo)\
**Post date:** [June 15, 2007, 6:48pm UTC](https://www.ruby-forum.com/t/mongrel-multiple-config-files/106947/2 "2007-06-15T18:48:32Z")

</div>

You know I had the same problem. I’m no Linux guru so I’ll just explain  
to  
the best of my ability how I overcame it.

I’m running Centos (Redhat) so I needed to set up the service so that my  
mongrel\_cluster will autostart my mongrels. I just made sure the symlink  
in  
the init.d folder on the production servers points to my production yml  
file  
since when I deploy it pushes both development and production yml files.

I don’t know if that helps but after trying a bunch of stuff with the  
app  
configs and not being able to get it working I gave up and approached it  
from outside the application and it works like a charm.

----- Original Message -----  
From: “Chris L.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Friday, June 15, 2007 6:54 AM  
Subject: [Rails-deploy] Mongrel & multiple config files

---

<div class="post-metadata">

**Author:** ![chrislo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/5e9695/32.png) [@chrislo](https://www.ruby-forum.com/u/chrislo)\
**Post date:** [June 18, 2007, 3:52pm UTC](https://www.ruby-forum.com/t/mongrel-multiple-config-files/106947/3 "2007-06-18T15:52:01Z")

</div>

Raul wrote:

> You know I had the same problem. I’m no Linux guru so I’ll just explain  
> to  
> the best of my ability how I overcame it.
> 
> I’m running Centos (Redhat) so I needed to set up the service so that my  
> mongrel\_cluster will autostart my mongrels. I just made sure the symlink  
> in  
> the init.d folder on the production servers points to my production yml  
> file  
> since when I deploy it pushes both development and production yml files.
> 
> I don’t know if that helps but after trying a bunch of stuff with the  
> app  
> configs and not being able to get it working I gave up and approached it  
> from outside the application and it works like a charm.

Thanks, Raul. For the time being I’ve backed off to using a single  
mongrel instance rather than a cluster, but that’s not ideal for  
production, and will only become less and less so as traffic increases.  
At the moment I have both staging and production environments running on  
the same box, but I could probably arrange something like this as  
they’re obviously in completely separate directories.

I can’t believe I’m unique in experiencing this. Anyone else?

-Chrisl

---

<div class="post-metadata">

**Author:** ![chrislo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/5e9695/32.png) [@chrislo](https://www.ruby-forum.com/u/chrislo)\
**Post date:** [June 29, 2007, 11:05am UTC](https://www.ruby-forum.com/t/mongrel-multiple-config-files/106947/4 "2007-06-29T11:05:55Z")

</div>

On Jun 23, 7:32 am, Paul H [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > From the sound of it, I am having the same experience. I am running
> 
> both a staging and production environment all on one server. I have a  
> mongrel cluster for each environment. What I am finding is that  
> Capistrano is deploying everything right and restarting the cluster  
> for either staging or production but for some reason only one rails  
> app is actually running at a time. Its getting old. I can make a  
> requyest from either staging or production and I see both of the  
> request in the production log. I am stumped.

Y’know, I’ve just gone back to this and tried it again, and well, darn  
it, it works perfectly.  
The only thing that I’ve changed is that I’ve supplied the path to the  
config file in full, and  
not as a relative path. This is in the light of some problems I had  
elsewhere, when I assumed  
that Capistrano was running the remote processes in the deployment  
directory, but it turned  
out it was running them in /

I was mulling this over as I was going to sleep last night (as one  
does) and wondered if that  
had been the root of my problems. Looks like it might have been.

-Chrisl

---

<div class="post-metadata">

**Author:** ![chrislo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/5e9695/32.png) [@chrislo](https://www.ruby-forum.com/u/chrislo)\
**Post date:** [June 23, 2007, 8:33am UTC](https://www.ruby-forum.com/t/mongrel-multiple-config-files/106947/5 "2007-06-23T08:33:21Z")

</div>

> From the sound of it, I am having the same experience. I am running  
> both a staging and production environment all on one server. I have a  
> mongrel cluster for each environment. What I am finding is that  
> Capistrano is deploying everything right and restarting the cluster  
> for either staging or production but for some reason only one rails  
> app is actually running at a time. Its getting old. I can make a  
> requyest from either staging or production and I see both of the  
> request in the production log. I am stumped.

Paul

On Jun 18, 6:52 am, Chris L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![chrislo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/5e9695/32.png) [@chrislo](https://www.ruby-forum.com/u/chrislo)\
**Post date:** [June 29, 2007, 4:28pm UTC](https://www.ruby-forum.com/t/mongrel-multiple-config-files/106947/6 "2007-06-29T16:28:38Z")

</div>

hmm, thanks for the update. I may give the full path route a try and  
see if  
it will work. Then I can remove my symlink hack and scrap any  
extraneous  
documentation for server setup!

Raul

----- Original Message -----  
From: “Chrisl” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: “Deploying Rails” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Friday, June 29, 2007 2:05 AM  
Subject: [Rails-deploy] Re: Mongrel & multiple config files
