• Stavros Sachtouris's avatar
    Implement clean shutdown with multiple UIs · f0f7db82
    Stavros Sachtouris authored
    To shutdown all UIs, one has to "stop" the heart of the UI session.
    The heart of a UI session is a database relation in the
    "session.db" database. It is emptied when a shutdown message is
    received by a running WebSocketProtocol instance.
    
    All other connections periodically check the heart and update its
    timestamp. When the tupple containing the session id is empty, all
    connections of the same sesion die.
    
    The WSGI server, which is running as a member of a SessionHelper
    instance, is shut down by a simpling threaded method launched by
    the SessionHelper before running the server. This method is called
    _shutdown_daemon and is polling the database every 4 seconds. When
    the database is empty, it sends a shutdown signal to the WSGI
    server.
    
    These changes affect the way an Agkyra daemon is launched, as well
    as the "launch_daemon" and "stop_daemon" CLI commands.
    f0f7db82
protocol.py 20 KB