From cb53fcb363d3f67fbc050a1c69f26a3f73763307 Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Thu, 26 Sep 2024 13:45:33 +0900 Subject: [PATCH] Set scheduler interval configurable --- world_boss/app/config.py | 2 ++ world_boss/app/scheduler.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/world_boss/app/config.py b/world_boss/app/config.py index 6b3bae1..f557189 100644 --- a/world_boss/app/config.py +++ b/world_boss/app/config.py @@ -32,6 +32,7 @@ class Settings(BaseSettings): headless_jwt_iss: str headless_jwt_algorithm: str planet_id: str + scheduler_interval: int = 60 * 5 class Config: env_file = ".env" @@ -70,6 +71,7 @@ class Config: "headless_jwt_iss": {"env": "HEADLESS_JWT_ISS"}, "headless_jwt_algorithm": {"env": "HEADLESS_JWT_ALGORITHM"}, "planet_id": {"env": "PLANET_ID"}, + "scheduler_interval": {"env": "SCHEDULER_INTERVAL"}, } diff --git a/world_boss/app/scheduler.py b/world_boss/app/scheduler.py index 3d5ae43..747136a 100644 --- a/world_boss/app/scheduler.py +++ b/world_boss/app/scheduler.py @@ -1,5 +1,6 @@ from apscheduler.schedulers.background import BackgroundScheduler +from world_boss.app.config import config from world_boss.app.tasks import check_season scheduler = BackgroundScheduler() @@ -9,4 +10,4 @@ def check(): check_season.delay() -scheduler.add_job(check, "interval", seconds=60 * 30) +scheduler.add_job(check, "interval", seconds=config.scheduler_interval)