From b085ba5ba3e263719f6e55ef4fc342bbd407a343 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Mon, 23 Aug 2004 20:08:49 +0000 Subject: [PATCH] HUP handling. --- src/Config.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Config.py b/src/Config.py index 23167e332..a1eae4f00 100644 --- a/src/Config.py +++ b/src/Config.py @@ -37,7 +37,9 @@ __revision__ = "$Id$" __author__ = 'Jeremy Fincher (jemfinch) ' import getopt +import signal +import supybot.log as log import supybot.conf as conf import supybot.utils as utils import supybot.world as world @@ -78,6 +80,17 @@ def getCapability(name): ### Do more later, for specific capabilities/sections. return capability +def _reload(): + ircdb.users.reload() + ircdb.channels.reload() + registry.open(world.registryFilename) + +def _hupHandler(sig, frame): + log.info('Received SIGHUP, reloading configuration.') + _reload() + +signal.signal(signal.SIGHUP, _hupHandler) + class Config(callbacks.Privmsg): def callCommand(self, method, irc, msg, *L): @@ -253,14 +266,11 @@ class Config(callbacks.Privmsg): Reloads the various configuration files (user database, channel database, registry, etc.). """ - ircdb.users.reload() - ircdb.channels.reload() - registry.open(world.registryFilename) + _reload() # This was factored out for SIGHUP handling. irc.replySuccess() reload = privmsgs.checkCapability(reload, 'owner') - Class = Config # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: