예제 #1
0
def shutdown(x=None):
    """
    This is a top level method which control the process of finishing the
    program.

    Calls method ``shutdown()`` in other modules.
    """
    lg.out(2, "shutdowner.shutdown " + str(x))
    from services import driver
    from main import control
    from main import events
    from logs import weblog
    from logs import webtraffic
    from system import tmpfile
    from system import run_upnpc
    from raid import eccmap
    from lib import net_misc
    from updates import git_proc
    from interface import api_jsonrpc_server
    from interface import api_rest_http_server
    from interface import ftp_server
    from userid import my_id
    from crypt import my_keys
    dl = []
    my_keys.shutdown()
    my_id.shutdown()
    ftp_server.shutdown()
    api_jsonrpc_server.shutdown()
    api_rest_http_server.shutdown()
    driver.shutdown()
    eccmap.shutdown()
    run_upnpc.shutdown()
    net_misc.shutdown()
    git_proc.shutdown()
    events.clear_subscribers()
    tmpfile.shutdown()
    control.shutdown()
    weblog.shutdown()
    webtraffic.shutdown()
    survived_automats = list(automat.objects().values())
    for a in survived_automats:
        if a.name != 'shutdowner':
            a.event('shutdown')
    return DeferredList(dl)
예제 #2
0
def shutdown(x=None):
    """
    This is a top level method which control the process of finishing the
    program.

    Calls method ``shutdown()`` in other modules.
    """
    if _Debug:
        lg.out(_DebugLevel, "shutdowner.shutdown " + str(x))
    dl = []
    try:
        from services import driver
        from main import control
        from main import events
        from main import listeners
        from logs import weblog
        from logs import webtraffic
        from system import tmpfile
        from system import run_upnpc
        from raid import eccmap
        from lib import net_misc
        from updates import git_proc
        from interface import api_rest_http_server
        from interface import api_web_socket
        # from interface import ftp_server
        from contacts import identitydb
        from crypt import my_keys
        from userid import id_url
        from userid import my_id
        my_keys.shutdown()
        my_id.shutdown()
        identitydb.shutdown()
        # ftp_server.shutdown()
        api_rest_http_server.shutdown()
        api_web_socket.shutdown()
        driver.shutdown()
        eccmap.shutdown()
        run_upnpc.shutdown()
        net_misc.shutdown()
        git_proc.shutdown()
        listeners.shutdown()
        events.shutdown()
        tmpfile.shutdown()
        control.shutdown()
        try:
            weblog.shutdown()
        except:
            lg.exc()
        try:
            webtraffic.shutdown()
        except:
            lg.exc()
        survived_automats = list(automat.objects().values())
        if survived_automats:
            lg.warn(
                'found %d survived state machines, sending "shutdown" event to them all'
                % len(survived_automats))
            for a in survived_automats:
                if a.name != 'shutdowner':
                    a.event('shutdown')
        survived_automats = list(automat.objects().values())
        if survived_automats:
            lg.warn(
                'still found %d survived state machines, executing "destroy()" method to them all'
                % len(survived_automats))
            for a in survived_automats:
                if a.name != 'shutdowner':
                    a.destroy()
        settings.shutdown()
        id_url.shutdown()
    except:
        lg.exc()
    # TODO: rework all shutdown() methods to return deferred objects
    return DeferredList(dl)