How to load the database.yml file again during runtime?

Hi, I have an application that allows the user to make changes to the
database.yml file so that he can connect to another database. However I
have to manually restart the application to make the changes in
database.yml effective. My question is: is there any way of making the
changes in database.yml effective from the application code? or at
least, is there any way of restarting the application from the
application code?


Don't know about restarting the app (I suspect not) but
ActiveRecord::Base.establish_connection might help you. Propagating
that change to all of your mongrels might be interesting.


I would think you could ping a URL which runs a shell script that would make the mongrel_cluster calls (or equiv) to restart the app. Use HTTP authentication for that URL of course, and it's recommended to run that URL as https (unless it's all on a LAN where you're not worried about snooping).

I've done this on another platform for a special application case.

I have a local script I use during dev to "restart" rails:

echo "stopping rails..."
mongrel_rails stop /Users/greg/Sites/{path_to_application}/log

echo "starting rails..."
cd /Users/greg/Sites/{path_to_application}
mongrel_rails start -d -p 3001
echo "done"
echo ""

So, something like that with the mongrel_cluster commands and without the echo feedback.

-- gw