Well... after spending about a week refactoring all configuration files and stuff, it's time to deploy. Hesitated for a second whether I should do it after hours, but then it's all tested and just a simple svn update. Why bother? Right after I svn update and restarted phusion passenger server. Bang! The whole app was down. It showed the config file wasn't being recognized and phusion passenger showed error trace on the screen. Worst deployment, ever!
Inside the rails app, I followed the instruction of using configuration yaml file. So created a config.yml file under config folder with lines like:
dashboard_server: srv6
email_track_server: srv6
redmine_server: srv6
Then in config/environment.rb, load that yaml file via:
APP_CONFIG = YAML.load_file("#{Rails.root}/config/config.yml")
Throughout the app, it's then reference as
APP_CONFIG['dashboard_server']
The problem is that APP_CONFIG wasn't loaded for some reason. So phusion passenger freaked out.
I know what went wrong, but don't know how to fix it. Why it's not loading? What prevented it? How to make it recognize it? What's the difference between production and development (as development works fine)? Google is your friend, but even google can't find the answer. I was puzzled, if that's the issue, there should be people asking questions. But I didn't see any.
Eventually I stumbled upon this Ryan Bates railscast: http://asciicasts.com/episodes/226-upgrading-to-rails-3-part-2
Although I'm not upgrading from Rails 2 to Rails 3, the same concept might still apply. I found one thing that I could try:
In config/application.rb file, before require 'rails/all', insert this:
require 'yaml'
APP_CONFIG = YAML.load(File.read(File.expand_path('../app_config.yml', __FILE__)))
Restart the server. Viola! We're back in business.
So it seems that YAML.load wasn't doing anything inside config/environment.rb, but rather it should be in config/application.rb? That's odd and I haven't yet thought through it.