Virtual hosts not using their own databases


#1

Hi there!

I just set up 3 instances of the same Rails app (nginx+mongrel_cluster)
http://pastie.org/336677 – but for some reason site1 and site2
(despite their own database.yml) end up using site3’s database.

What on earth is going on here?

Thanks y’all,
RV


#2

Redd V. wrote:

Does each virtual host have its own instance of the database server
running?


#3

Norm wrote:

Does each virtual host have its own instance of the database server
running?

No actually I’m only running one MySQL 5.1 server instance. The OS is
FreeBSD.

Thank you.


#4

Redd V. wrote:

When you say “their own database.yml” do you mean that you have
differently named databases in each database.yml? Stupid question but
stuff happens.


#5

Norm wrote:

Redd V. wrote:

When you say “their own database.yml” do you mean that you have
differently named databases in each database.yml? Stupid question but
stuff happens.

Yes, exactly, like site1_production, site2_production and so on.


#6

John Y. wrote:

So if you start only site2’s mongrel cluster it actually uses the data
site3_production, though it’s database.yml specifies site2_production?

also, I think you forgot the ‘t.’ in your rake tasks

task :install_site3 => :environment do |t|
t.load_database
t.create_keys
t.create_preferences
t.create_admin
end

Actually I fixed it now though. It turned out running “rake
install_site1 RAILS_ENV=production” also ran rake install_site2 and rake
install_site3 since they were all in the same directory. Deleting the
other rake scripts for each instance of my Rails app made everything
work just fine.

Much obliged everyone!


#7

Redd V. wrote:

Norm wrote:

Redd V. wrote:

When you say “their own database.yml” do you mean that you have
differently named databases in each database.yml? Stupid question but
stuff happens.

Yes, exactly, like site1_production, site2_production and so on.

So if you start only site2’s mongrel cluster it actually uses the data
site3_production, though it’s database.yml specifies site2_production?

also, I think you forgot the ‘t.’ in your rake tasks

task :install_site3 => :environment do |t|
t.load_database
t.create_keys
t.create_preferences
t.create_admin
end