Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Reloading Rails Dynamically

#44

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?

Reported by Alex MacCaw · February 13th, 2008 @ 03:32 AM

State: invalid
Milestone: Future
Assigned to: macournoyer macournoyer

Activity

  1. macournoyer
    macournoyer
    • 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.

    February 13th, 2008 @ 12:55 PM

  2. Alex MacCaw
    Alex MacCaw

    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?

    February 13th, 2008 @ 06:50 PM

  3. macournoyer
    macournoyer
    • State changed from hold to open

    That definitely require some testing before including. But it looks very interesting.

    thx for the patch Alex

    February 13th, 2008 @ 08:54 PM

  4. Alex MacCaw
    Alex MacCaw

    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?

    February 14th, 2008 @ 01:32 PM

  5. macournoyer
  6. Alex MacCaw
    Alex MacCaw

    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?

    February 14th, 2008 @ 06:17 PM

  7. macournoyer
    macournoyer
    • Tag set to rails
    • State changed from open to invalid

    create another ticket w/ patch for rolling restart as an option

    March 16th, 2009 @ 09:03 PM

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.