mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-24 03:29:28 +01:00
plugins: make DB save delay configurable
This commit is contained in:
parent
db3517b43a
commit
00766041f3
@ -36,6 +36,11 @@ bot:
|
||||
# False.
|
||||
protect_services: false
|
||||
|
||||
# Determines how long plugins should wait (in seconds) before flushing their
|
||||
# databases to disk. Defaults to 300 seconds. Changes here require a reload
|
||||
# of all database-enabled plugins to take effect.
|
||||
save_delay: 300
|
||||
|
||||
login:
|
||||
# PyLink administrative login - Change this, or the service will not start!
|
||||
user: admin
|
||||
|
@ -6,7 +6,7 @@ import collections
|
||||
import threading
|
||||
import json
|
||||
|
||||
from pylinkirc import utils
|
||||
from pylinkirc import utils, conf
|
||||
from pylinkirc.log import log
|
||||
|
||||
mydesc = ("The \x02Automode\x02 plugin provides simple channel ACL management by giving prefix modes "
|
||||
@ -21,6 +21,8 @@ dbname = utils.getDatabaseName('automode')
|
||||
db = collections.defaultdict(dict)
|
||||
exportdb_timer = None
|
||||
|
||||
save_delay = conf.conf['bot'].get('save_delay', 300)
|
||||
|
||||
def loadDB():
|
||||
"""Loads the Automode database, silently creating a new one if this fails."""
|
||||
global db
|
||||
@ -50,8 +52,7 @@ def scheduleExport(starting=False):
|
||||
# thing after start (i.e. DB has just been loaded).
|
||||
exportDB()
|
||||
|
||||
# TODO: possibly make delay between exports configurable
|
||||
exportdb_timer = threading.Timer(30, scheduleExport)
|
||||
exportdb_timer = threading.Timer(save_delay, scheduleExport)
|
||||
exportdb_timer.name = 'Automode exportDB Loop'
|
||||
exportdb_timer.start()
|
||||
|
||||
|
@ -5,7 +5,7 @@ import threading
|
||||
import string
|
||||
from collections import defaultdict
|
||||
|
||||
from pylinkirc import utils, world
|
||||
from pylinkirc import utils, world, conf
|
||||
from pylinkirc.log import log
|
||||
|
||||
### GLOBAL (statekeeping) VARIABLES
|
||||
@ -15,7 +15,7 @@ spawnlocks = defaultdict(threading.RLock)
|
||||
spawnlocks_servers = defaultdict(threading.RLock)
|
||||
|
||||
exportdb_timer = None
|
||||
|
||||
save_delay = conf.conf['bot'].get('save_delay', 300)
|
||||
db = {}
|
||||
dbname = utils.getDatabaseName('pylinkrelay')
|
||||
|
||||
@ -193,8 +193,7 @@ def scheduleExport(starting=False):
|
||||
# thing after start (i.e. DB has just been loaded).
|
||||
exportDB()
|
||||
|
||||
# TODO: possibly make delay between exports configurable
|
||||
exportdb_timer = threading.Timer(30, scheduleExport)
|
||||
exportdb_timer = threading.Timer(save_delay, scheduleExport)
|
||||
exportdb_timer.name = 'PyLink Relay exportDB Loop'
|
||||
exportdb_timer.start()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user