Here's my suggestion on graceful shutdown.

1) Modify your I/O Handler (or ProtocolHandler) to maintain the list of
connected sessions.  sessionOpened() and sessionClosed() would be the best
place to do this.
2) Unbind the service so there cannot be more new sessions.  The existing
sessions will not be disconnected at this moment.
3) Close all sessions in the list you've been maintaining at step (1).

Regarding the timeout stuff, it depends on the contract between clients and
a server, so the implementation can change depending on it.  My suggestion
is just to close the sessions immediately because a server that takes
minutes to shut itself down makes administrators unhappy.

HTH,
Trustin

On 8/6/06, Hanson Char <[EMAIL PROTECTED]> wrote:

Hi,

I am interested in your thoughts and suggestions in implementing a
graceful shutdown of a Mina server.  Please read below for details.

Hanson Char

Implementing Graceful Shutdown
========================
We have a server implemented in Mina 0.8.2, and are thinking of
implementing a graceful shutdown of the server upon certain event
(such as trapping a SIGINT or SIGTERM).

The shutdown basically needs to:
1) stop any new connection from being made, and
2) closes all existing open sessions;

For (2), however, I am thinking instead of closing the outstanding
open sessions immediately, maybe a better approach would be to wait
for the existing write's to finish prior to closing the sessions ?

Specifically, for each existing open session,
1) check if it is idle and if so close the session immediately;
2) if not, wait for up to 10 seconds (or whatever timeout parameter),
or until it's idle, then close the session;

Thoughts ?  Suggestions ?

Thanks in advance.




--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6

Reply via email to