On Tue, Mar 2, 2010 at 2:52 PM, Abhijit Hiremagalur <a...@pivotallabs.com> wrote: > Looks like a Java shutdown hook would lets us clean up resources > properly on a SIGINT or SIGHUP: > https://gist.github.com/78daf7e68f8bb9801305 > > And this seems fine with my Java developer hat on. > > However, wearing my Ruby developer hat it feels a little kludgy given > in MRI all I can cleanup in a simple ensure block.
Well, it feels a little kludgy to me that MRI users have to spin up multiple processes to use multiple cores and periodically kill their Rails instances to keep them from getting "stale". But MRI and JRuby have wildly different runtimes, so some differences are to be expected :) On Tue, Mar 2, 2010 at 4:14 PM, Abhijit Hiremagalur <a...@pivotallabs.com> wrote: > After some discussion with my co-workers we're leaning towards simply > emulating MRI's handling of SIGTERM, SIGHUP and SIGINT with custom > signal handlers that raise the appropriate SignalException. If you're basically using JRuby as a standalone process in the same way as MRI, I think this is totally acceptable. You're not treating it as a typical Java/JVM process, where the Java/JVM defaults for signal-handling would be expected. > This approach results in the ensure being executed under JRuby as it > is in MRI and also doesn't appear to interfere with any Java shutdown > hooks, implying the JVM probably continues to shutdown normally. For SIGHUP this is probably true; I don't think Java normally intercepts HUP to do anything with it. I could be wrong, but if you're installing a signal handler and it's not interfering with normal JVM shutdown, I think you're fine. > Here's a gist with the approach we're planning to use: > http://gist.github.com/320008 > > I'd imagine JRuby should do something similar eventually unless > there's something about what we've done that makes it a really idea. > If there is then I hope somebody reading this will point it out. We could possibly hook HUP if the JVM isn't already grabbing it. My primary concern is to avoid changing existing signal-handling behavior that JVM users would expect to see, so automatically hooking INT is off the table but HUP may not be. - Charlie --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email