mirror of
https://github.com/Genshin-bots/gsuid_core.git
synced 2025-05-12 06:55:49 +08:00
🎨 config.json
提供设置aps参数misfire_grace_time
This commit is contained in:
parent
574cec609a
commit
e48daef821
@ -1,8 +1,21 @@
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
||||
|
||||
from gsuid_core.logger import logger
|
||||
from gsuid_core.config import core_config
|
||||
|
||||
misfire_grace_time = core_config.get_config('misfire_grace_time')
|
||||
|
||||
executor = ThreadPoolExecutor(max_workers=10)
|
||||
job_defaults = {'misfire_grace_time': misfire_grace_time, 'coalesce': True}
|
||||
options = {
|
||||
'executor': executor,
|
||||
'job_defaults': job_defaults,
|
||||
'timezone': 'Asia/Shanghai',
|
||||
}
|
||||
scheduler = AsyncIOScheduler()
|
||||
scheduler.configure(options)
|
||||
|
||||
|
||||
async def start_scheduler():
|
||||
|
@ -9,6 +9,7 @@ CONFIG_DEFAULT = {
|
||||
'PORT': '8765',
|
||||
'masters': [],
|
||||
'superusers': [],
|
||||
'misfire_grace_time': 90,
|
||||
'log': {
|
||||
'level': 'INFO',
|
||||
# ...
|
||||
@ -17,6 +18,7 @@ CONFIG_DEFAULT = {
|
||||
'sv': {},
|
||||
}
|
||||
STR_CONFIG = Literal['HOST', 'PORT']
|
||||
INT_CONFIG = Literal['misfire_grace_time']
|
||||
LIST_CONFIG = Literal['superusers', 'masters', 'command_start']
|
||||
DICT_CONFIG = Literal['sv', 'log']
|
||||
|
||||
@ -57,7 +59,11 @@ class CoreConfig:
|
||||
def get_config(self, key: LIST_CONFIG) -> List:
|
||||
...
|
||||
|
||||
def get_config(self, key: str) -> Union[str, Dict, List]:
|
||||
@overload
|
||||
def get_config(self, key: INT_CONFIG) -> int:
|
||||
...
|
||||
|
||||
def get_config(self, key: str) -> Union[str, Dict, List, int]:
|
||||
if key in self.config:
|
||||
return self.config[key]
|
||||
elif key in CONFIG_DEFAULT:
|
||||
|
@ -1,4 +1,5 @@
|
||||
from gsuid_core.aps import scheduler
|
||||
from gsuid_core.logger import logger
|
||||
from gsuid_core.server import GsServer
|
||||
|
||||
gss = GsServer()
|
||||
@ -11,6 +12,7 @@ for i in scheduler.get_jobs():
|
||||
if i.name not in repeat_jobs:
|
||||
repeat_jobs[i.name] = i
|
||||
else:
|
||||
logger.warning(f'发现重复函数名定时任务{i.name}, 移除该任务...')
|
||||
scheduler.remove_job(i.id)
|
||||
|
||||
del repeat_jobs
|
||||
|
Loading…
x
Reference in New Issue
Block a user