mirror of
https://github.com/jlu5/PyLink.git
synced 2025-02-20 07:20:59 +01:00
plugins: make DB save delay configurable
This commit is contained in:
parent
db3517b43a
commit
00766041f3
@ -36,6 +36,11 @@ bot:
|
|||||||
# False.
|
# False.
|
||||||
protect_services: 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:
|
login:
|
||||||
# PyLink administrative login - Change this, or the service will not start!
|
# PyLink administrative login - Change this, or the service will not start!
|
||||||
user: admin
|
user: admin
|
||||||
|
@ -6,7 +6,7 @@ import collections
|
|||||||
import threading
|
import threading
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from pylinkirc import utils
|
from pylinkirc import utils, conf
|
||||||
from pylinkirc.log import log
|
from pylinkirc.log import log
|
||||||
|
|
||||||
mydesc = ("The \x02Automode\x02 plugin provides simple channel ACL management by giving prefix modes "
|
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)
|
db = collections.defaultdict(dict)
|
||||||
exportdb_timer = None
|
exportdb_timer = None
|
||||||
|
|
||||||
|
save_delay = conf.conf['bot'].get('save_delay', 300)
|
||||||
|
|
||||||
def loadDB():
|
def loadDB():
|
||||||
"""Loads the Automode database, silently creating a new one if this fails."""
|
"""Loads the Automode database, silently creating a new one if this fails."""
|
||||||
global db
|
global db
|
||||||
@ -50,8 +52,7 @@ def scheduleExport(starting=False):
|
|||||||
# thing after start (i.e. DB has just been loaded).
|
# thing after start (i.e. DB has just been loaded).
|
||||||
exportDB()
|
exportDB()
|
||||||
|
|
||||||
# TODO: possibly make delay between exports configurable
|
exportdb_timer = threading.Timer(save_delay, scheduleExport)
|
||||||
exportdb_timer = threading.Timer(30, scheduleExport)
|
|
||||||
exportdb_timer.name = 'Automode exportDB Loop'
|
exportdb_timer.name = 'Automode exportDB Loop'
|
||||||
exportdb_timer.start()
|
exportdb_timer.start()
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import threading
|
|||||||
import string
|
import string
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from pylinkirc import utils, world
|
from pylinkirc import utils, world, conf
|
||||||
from pylinkirc.log import log
|
from pylinkirc.log import log
|
||||||
|
|
||||||
### GLOBAL (statekeeping) VARIABLES
|
### GLOBAL (statekeeping) VARIABLES
|
||||||
@ -15,7 +15,7 @@ spawnlocks = defaultdict(threading.RLock)
|
|||||||
spawnlocks_servers = defaultdict(threading.RLock)
|
spawnlocks_servers = defaultdict(threading.RLock)
|
||||||
|
|
||||||
exportdb_timer = None
|
exportdb_timer = None
|
||||||
|
save_delay = conf.conf['bot'].get('save_delay', 300)
|
||||||
db = {}
|
db = {}
|
||||||
dbname = utils.getDatabaseName('pylinkrelay')
|
dbname = utils.getDatabaseName('pylinkrelay')
|
||||||
|
|
||||||
@ -193,8 +193,7 @@ def scheduleExport(starting=False):
|
|||||||
# thing after start (i.e. DB has just been loaded).
|
# thing after start (i.e. DB has just been loaded).
|
||||||
exportDB()
|
exportDB()
|
||||||
|
|
||||||
# TODO: possibly make delay between exports configurable
|
exportdb_timer = threading.Timer(save_delay, scheduleExport)
|
||||||
exportdb_timer = threading.Timer(30, scheduleExport)
|
|
||||||
exportdb_timer.name = 'PyLink Relay exportDB Loop'
|
exportdb_timer.name = 'PyLink Relay exportDB Loop'
|
||||||
exportdb_timer.start()
|
exportdb_timer.start()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user