Rails on DreamHost: How to restart your app after a change…

If you, like me, and like so many countless people, host a Rails site on DreamHost, sometimes you need to make a tiny change to the code. (sometimes a BIG change…) But the changes don’t seem to take effect! Well, they how and why about that is pretty heady stuff I won’t go into here, but I will tell you how to restart your app the DreamHost way!

In development mode, Rails will reload (almost) all changes and things seem so easy and fun. But in production mode, things don’t get reloaded so often, in fact they get cached, to speed things up a bit. No big deal.

On DreamHost, log in to your DreamHost Web Panel, then click on Domains, then Manage Domains. In the list, locate the domain of the site you need to restart, click on “edit” in the “Web Hosting” column.

In the next screen, in the section “Fully Hosted” simply click on “Fully Host this Domain Now”, even though you already are doing that. This will restart your Rails app. Granted, I don’t know what might happen if you have somebody updating/adding a record to the database in the midst of this. I suspect DreamHost is clever enough to make sure any such procedures finish first, but just so you know, it is entirely possible to end up with some screwed up records in the database in any web app. This is more of an issue if your site is a big, busy site with thousands of visitors, but if your site is one of those, then you would be a fool to do things this way…

3 comments ↓

#1 Rockwell on 08.14.08 at 8:53 pm

I was really hoping this could be done programmatically, but I’ve done a lot of searching and have come up with nothing but this solution.

So, thank you!

#2 Rockwell on 08.14.08 at 9:04 pm

Okay, so I just lied. There is a solution here:

http://alexbrie.net/1960/dreamhost-and-mod_rails-for-your-tiny-rails-application/

If you’re running Passenger, you can create a file /tmp/restart.txt. Passenger looks for it and reloads the app if it exists. It also deletes restart.txt, so the next time you diff your files and upload them, the restart gets added back again.

Hope this helps.

#3 max on 10.23.08 at 11:23 am

Hey! What about create a ssh user and do the following: open console and type in $ touch /your_web_app_directory/tmp/restart.txt
After executing that command in shell, you should see an updated web site, with all diffs you just made.

Leave a Comment