Reloading Rails Dynamically
Reported by Alex MacCaw | February 13th, 2008 @ 03:32 AM | in Future
I'm not sure if this is a good idea (or possible) and I'm not sure if this is the right forum for it.
However, wouldn't it be nice to deploy without having to restart anything. Is it not possible to catch a HUP signal in Thin to trigger reloading of the Rails app? I think the ruby 'load' method reloads the file, even if it's already loaded (unlike require). What do you think?
Comments and changes to this ticket
-
macournoyer February 13th, 2008 @ 12:55 PM
- Milestone set to Future
- State changed from new to hold
Mongrel does it w/ the HUP signal but it's not working very well.
As it's written when Mongrel boots:
Rails signals registered. HUP => reload (without restart). It might not work well.
I don't think anybody is using this.
But if you got a stable way to reload a Rails app, I'd be glad to include it.
-
Alex MacCaw February 13th, 2008 @ 06:50 PM
Well, here's the patch. I've also added reload support to the runner, so you can do:
thin reload --servers 3 -e production
and it'll go through all of them giving them the HUP signal.
I'll do a bit more testing to see how stable it is (it's working fine at the moment though). Basically I'm doing exactly what the console's reload! method does, but with a few added extras that ensure controllers (and hopefully plugins) get reloaded too. Maybe it would be a good idea to catch a reload exception (if any) and restart instead?
-
macournoyer February 13th, 2008 @ 08:54 PM
- State changed from hold to open
That definitely require some testing before including. But it looks very interesting.
thx for the patch Alex
-
Alex MacCaw February 14th, 2008 @ 01:32 PM
Unfortunately, a colleague from work tells me that it's likely to suffer from memory leaks, even if you kick of the garbage collector manually. So restarting is the only sure way of cleaning up. I suppose the other option would be a rolling restart, perhaps that could be added to thin's cluster support?
-
macournoyer February 14th, 2008 @ 02:08 PM
You mean something like this http://blog.carlmercier.com/2007... ?
-
Alex MacCaw February 14th, 2008 @ 06:17 PM
Yes, we could have an options to do a simple rolling restart, i.e. making sure only one thin server is down at any time. Would you like a patch for that?
-
macournoyer March 16th, 2009 @ 09:03 PM
- Tag set to rails
- State changed from open to invalid
create another ticket w/ patch for rolling restart as an option
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป