I am using berkeleydb and I need to cleanly close the environment when the server is being stopped and after all clients have disconnected. This is the best thing I have thought of so far, there must be a better way though. - use a class variable to track number of open connections - when a signal is caught, don''t accept any new connections by calling close_connection in receive_data and immediately returning. - when there are no more open connection, close the db environment - call stop_event_loop Chris
Francis Cianfrocca
2006-Oct-19 05:53 UTC
[Eventmachine-talk] trapping signals/clean shutdowns
On 10/19/06, snacktime <snacktime at gmail.com> wrote:> > I am using berkeleydb and I need to cleanly close the environment when > the server is being stopped and after all clients have disconnected. > This is the best thing I have thought of so far, there must be a > better way though. > > - use a class variable to track number of open connections > - when a signal is caught, don''t accept any new connections by calling > close_connection in receive_data and immediately returning. > - when there are no more open connection, close the db environment > - call stop_event_loopChris, Jeff Rose suggested long ago that EM should have its own signal handlers. That''s a great idea and we really should do it. Sounds like you want something a bit different, however- the ability to shut down the EM after all network connections have closed. Analogous to what the TCP connections do now with the EventMachine::Connection#close_after_writing call. Can you be more specific about your requirements? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20061019/3f50bca8/attachment.html
> > Chris, Jeff Rose suggested long ago that EM should have its own signal > handlers. That''s a great idea and we really should do it. Sounds like you > want something a bit different, however- the ability to shut down the EM > after all network connections have closed. Analogous to what the TCP > connections do now with the > EventMachine::Connection#close_after_writing call. Can you > be more specific about your requirements?Actually I wasn''t thinking clearly, I forgot that I can use unbind to take care of any cleanup that needs to be done when stop_event_loop runs down all the connections. And I can use an admin interface of some type like a telnet port or something to let the app know to stop accepting connections. Chris