3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-28 13:42:37 +01:00

coreplugin: tell plugins to exit cleanly before closing connections

Relay tends to hang on shutdown unless it's specifically told to exit/unload first. This is probably a better solution, as it works with other plugins too.
This commit is contained in:
James Lu 2016-03-05 10:22:00 -08:00
parent 9b0db81068
commit 3527960d18

View File

@ -182,10 +182,22 @@ def shutdown(irc, source, args):
Exits PyLink by disconnecting all networks."""
utils.checkAuthenticated(irc, source, allowOper=False)
u = irc.users[source]
log.info('(%s) SHUTDOWN requested by "%s!%s@%s", exiting...', irc.name, u.nick,
u.ident, u.host)
for name, plugin in world.plugins.items():
# Before closing connections, tell all plugins to shutdown cleanly first.
if hasattr(plugin, 'die'):
log.debug('coreplugin: Running die() on plugin %s due to shutdown.', name)
try:
plugin.die(irc)
except: # But don't allow it to crash the server.
log.exception('coreplugin: Error occurred in die() of plugin %s, skipping...', name)
for ircobj in world.networkobjects.values():
# Disable auto-connect first by setting the time to negative.
# Disconnect all our networks. Disable auto-connect first by setting
# the time to negative.
ircobj.serverdata['autoconnect'] = -1
ircobj.disconnect()