mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-23 19:19:31 +01:00
control: try a more stable force-shutdown routine
This commit is contained in:
parent
050721af5b
commit
a3f122fee4
@ -4,11 +4,14 @@ control.py - Implements SHUTDOWN and REHASH functionality.
|
||||
import signal
|
||||
import os
|
||||
import threading
|
||||
import sys
|
||||
|
||||
from pylinkirc import world, utils, conf, classes
|
||||
from pylinkirc.log import log, makeFileLogger, stopFileLoggers, stdoutLogLevel
|
||||
from . import permissions
|
||||
|
||||
tried_shutdown = False
|
||||
|
||||
def remove_network(ircobj):
|
||||
"""Removes a network object from the pool."""
|
||||
# Disable autoconnect first by setting the delay negative.
|
||||
@ -18,6 +21,12 @@ def remove_network(ircobj):
|
||||
|
||||
def _shutdown(irc=None):
|
||||
"""Shuts down the Pylink daemon."""
|
||||
global tried_shutdown
|
||||
if tried_shutdown: # We froze on shutdown last time, so immediately abort.
|
||||
sys.exit()
|
||||
|
||||
tried_shutdown = True
|
||||
|
||||
for name, plugin in world.plugins.items():
|
||||
# Before closing connections, tell all plugins to shutdown cleanly first.
|
||||
if hasattr(plugin, 'die'):
|
||||
|
Loading…
Reference in New Issue
Block a user