diff --git a/scripts/supybot b/scripts/supybot index 85dd5a8a9..a7d4cdc09 100755 --- a/scripts/supybot +++ b/scripts/supybot @@ -249,6 +249,7 @@ if __name__ == '__main__': if world.dying: log.info('Finished writing registry file.') world.flushers.append(closeRegistry) + world.registryFilename = registryFilename nick = options.nick or conf.supybot.nick() user = options.user or conf.supybot.user() diff --git a/src/Config.py b/src/Config.py index c373f0821..330fa2a04 100644 --- a/src/Config.py +++ b/src/Config.py @@ -37,6 +37,7 @@ import getopt import conf import utils +import world import ircdb import plugins import ircutils @@ -47,7 +48,6 @@ import callbacks ### # Now, to setup the registry. ### -import registry class InvalidRegistryName(callbacks.Error): pass @@ -210,9 +210,9 @@ class Config(callbacks.Privmsg): Reloads the various configuration files (user database, channel database, registry, etc.). """ - # TODO: Reload registry. ircdb.users.reload() ircdb.channels.reload() + registry.open(world.registryFilename) irc.replySuccess() reload = privmsgs.checkCapability(reload, 'owner') diff --git a/src/conf.py b/src/conf.py index 8c87dd636..eef919e1a 100644 --- a/src/conf.py +++ b/src/conf.py @@ -352,6 +352,12 @@ supybot.register('pingInterval', registry.Integer(120, """Determines the number of seconds between sending pings to the server, if pings are being sent to the server.""")) +supybot.register('flush', registry.Boolean(True, """Determines whether the bot +will periodically flush data and configuration files to disk. Generally, the +only time you'll want to set this to False is when you want to modify those +configuration files by hand and don't want the bot to flush its current version +over your modifications.""")) + ### # Driver stuff. ### diff --git a/src/world.py b/src/world.py index 5c0df355c..a2e59d554 100644 --- a/src/world.py +++ b/src/world.py @@ -66,6 +66,8 @@ ircs = [] # A list of all the IRCs. flushers = [] # A periodic function will flush all these. +registryFilename = None + def flush(): """Flushes all the registered flushers.""" for f in flushers: @@ -85,14 +87,19 @@ def upkeep(): pass if gc.garbage: log.warning('Uncollectable garbage: %s', gc.garbage) - if True: # XXX: Replace this with the registry variable. + flushed = conf.supybot.flush() + if flushed: flush() if not dying: log.debug('Regexp cache size: %s', len(sre._cache)) log.debug('Pattern cache size: %s'%len(ircutils._patternCache)) log.debug('HostmaskPatternEqual cache size: %s' % len(ircutils._hostmaskPatternEqualCache)) - log.info('%s Flushers flushed and garbage collected.', log.timestamp()) + timestamp = log.timestamp() + if flushed: + log.info('%s Flushers flushed and garbage collected.', timestamp) + else: + log.info('%s Garbage collected.', timestamp) return collected def makeDriversDie():