Made the registry dynamically reloadable as well as added a supybot.flush configuration variable.

This commit is contained in:
Jeremy Fincher 2004-02-03 22:58:54 +00:00
parent 1df9b64c39
commit 4c8f3d5314
4 changed files with 18 additions and 4 deletions

View File

@ -249,6 +249,7 @@ if __name__ == '__main__':
if world.dying: if world.dying:
log.info('Finished writing registry file.') log.info('Finished writing registry file.')
world.flushers.append(closeRegistry) world.flushers.append(closeRegistry)
world.registryFilename = registryFilename
nick = options.nick or conf.supybot.nick() nick = options.nick or conf.supybot.nick()
user = options.user or conf.supybot.user() user = options.user or conf.supybot.user()

View File

@ -37,6 +37,7 @@ import getopt
import conf import conf
import utils import utils
import world
import ircdb import ircdb
import plugins import plugins
import ircutils import ircutils
@ -47,7 +48,6 @@ import callbacks
### ###
# Now, to setup the registry. # Now, to setup the registry.
### ###
import registry
class InvalidRegistryName(callbacks.Error): class InvalidRegistryName(callbacks.Error):
pass pass
@ -210,9 +210,9 @@ class Config(callbacks.Privmsg):
Reloads the various configuration files (user database, channel Reloads the various configuration files (user database, channel
database, registry, etc.). database, registry, etc.).
""" """
# TODO: Reload registry.
ircdb.users.reload() ircdb.users.reload()
ircdb.channels.reload() ircdb.channels.reload()
registry.open(world.registryFilename)
irc.replySuccess() irc.replySuccess()
reload = privmsgs.checkCapability(reload, 'owner') reload = privmsgs.checkCapability(reload, 'owner')

View File

@ -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 number of seconds between sending pings to the server, if pings are being sent
to the server.""")) 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. # Driver stuff.
### ###

View File

@ -66,6 +66,8 @@ ircs = [] # A list of all the IRCs.
flushers = [] # A periodic function will flush all these. flushers = [] # A periodic function will flush all these.
registryFilename = None
def flush(): def flush():
"""Flushes all the registered flushers.""" """Flushes all the registered flushers."""
for f in flushers: for f in flushers:
@ -85,14 +87,19 @@ def upkeep():
pass pass
if gc.garbage: if gc.garbage:
log.warning('Uncollectable garbage: %s', 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() flush()
if not dying: if not dying:
log.debug('Regexp cache size: %s', len(sre._cache)) log.debug('Regexp cache size: %s', len(sre._cache))
log.debug('Pattern cache size: %s'%len(ircutils._patternCache)) log.debug('Pattern cache size: %s'%len(ircutils._patternCache))
log.debug('HostmaskPatternEqual cache size: %s' % log.debug('HostmaskPatternEqual cache size: %s' %
len(ircutils._hostmaskPatternEqualCache)) 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 return collected
def makeDriversDie(): def makeDriversDie():