Problems with server shutdown - Linux

This is a discussion on Problems with server shutdown - Linux ; I have TCP server that accepts client and then receives data from them. Server has SIGTERM handler, on which all sockets are closed and server exits. If server has several clients connected and I manually send it kill -TERM everything ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Problems with server shutdown

  1. Problems with server shutdown

    I have TCP server that accepts client and then receives data from them.
    Server has SIGTERM handler, on which all sockets are closed and server
    exits.
    If server has several clients connected and I manually send it kill
    -TERM everything goes correct: client application's
    sockets are disconnected and server shuts down the right way. But if I
    reboot machine some strange behavior occur: client application's
    sockets still think they are connected, and after server receives
    SIGTERM all semaphores that were in blocked state become unblocked.
    Can someone explain me what's going on?


  2. Re: Problems with server shutdown

    On 27 Oct 2006 06:38:34 -0700 John Smith wrote:

    | I have TCP server that accepts client and then receives data from them.
    | Server has SIGTERM handler, on which all sockets are closed and server
    | exits.
    | If server has several clients connected and I manually send it kill
    | -TERM everything goes correct: client application's
    | sockets are disconnected and server shuts down the right way. But if I
    | reboot machine some strange behavior occur: client application's
    | sockets still think they are connected, and after server receives
    | SIGTERM all semaphores that were in blocked state become unblocked.
    | Can someone explain me what's going on?

    Your system shutdown script are disabling network interfaces before the
    final termination is done. You need to write an init script for your
    server (daemon) that performs the server process shutdown in designated
    shutdown order instead of waiting for the final SIGTERM that cleans out
    the rest. All network daemons need to do this. The most common means
    is for the daemon (your server program) to write its process ID number
    to a file, when started, for the script to read when it's time to shut
    it down. Than the script can set it a specific SIGTERM or whatever other
    signal you might want to do for a more graceful shutdown.

    --
    |---------------------------------------/----------------------------------|
    | Phil Howard KA9WGN (ka9wgn.ham.org) / Do not send to the address below |
    | first name lower case at ipal.net / spamtrap-2006-10-27-1711@ipal.net |
    |------------------------------------/-------------------------------------|

  3. Re: Problems with server shutdown

    Thanks for reply.

    The problem was my daemon haven't created lock file, that is checked on
    runlevel change -- if no lock file present daemon is not stopped.


+ Reply to Thread