fix: reopen clears restored_at, wire settings, docs, startup warning
This commit is contained in:
+12
-3
@@ -8,6 +8,7 @@ from apscheduler.triggers.cron import CronTrigger
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import JSONResponse
|
||||
from .core.config import settings as app_settings
|
||||
from .core.db import SessionLocal, engine, get_scheduler_db
|
||||
from .core.exceptions import CodedHTTPException, coded_http_exception_handler
|
||||
from .models import Base
|
||||
@@ -60,19 +61,27 @@ async def lifespan(app: FastAPI):
|
||||
db.commit()
|
||||
logger.info("Database tables created/verified.")
|
||||
|
||||
if app_settings.SECRET_KEY in {
|
||||
"change-me-in-production-32-chars-min",
|
||||
"change-me-in-production-use-a-32-char-random-string",
|
||||
}:
|
||||
logging.warning(
|
||||
"SECURITY: SECRET_KEY is set to the insecure default. Set a strong SECRET_KEY env var before any non-local use."
|
||||
)
|
||||
|
||||
scheduler: BackgroundScheduler | None = None
|
||||
is_testing = bool(os.environ.get("PYTEST_CURRENT_TEST") or "pytest" in sys.modules)
|
||||
if not is_testing:
|
||||
_scheduled_alert_job()
|
||||
scheduler = BackgroundScheduler(timezone="Asia/Kolkata")
|
||||
scheduler = BackgroundScheduler(timezone=app_settings.TIMEZONE)
|
||||
scheduler.add_job(
|
||||
_scheduled_alert_job,
|
||||
trigger=CronTrigger(hour=6, minute=0, timezone="Asia/Kolkata"),
|
||||
trigger=CronTrigger(hour=6, minute=0, timezone=app_settings.TIMEZONE),
|
||||
id="daily_alert_check",
|
||||
replace_existing=True,
|
||||
)
|
||||
scheduler.start()
|
||||
logger.info("APScheduler daily alert check started (06:00 Asia/Kolkata).")
|
||||
logger.info("APScheduler daily alert check started (06:00 %s).", app_settings.TIMEZONE)
|
||||
|
||||
logger.info("Poona Hospital AMS started.")
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user