feat: add settings.lnbits_running (#2450)

* feat: add `settings.lnbits_runing `
This commit is contained in:
Vlad Stan
2024-04-22 12:33:53 +03:00
committed by GitHub
parent e91096c535
commit 4ac30116a9
21 changed files with 41 additions and 26 deletions
+7 -2
View File
@@ -69,6 +69,8 @@ from .tasks import (
async def startup(app: FastAPI):
settings.lnbits_running = True
# wait till migration is done
await migrate_databases()
@@ -104,6 +106,9 @@ async def startup(app: FastAPI):
async def shutdown():
logger.warning("LNbits shutting down...")
settings.lnbits_running = False
# shutdown event
cancel_all_tasks()
@@ -181,7 +186,7 @@ async def check_funding_source() -> None:
max_retries = settings.funding_source_max_retries
retry_counter = 0
while True:
while settings.lnbits_running:
try:
logger.info(f"Connecting to backend {funding_source.__class__.__name__}...")
error_message, balance = await funding_source.status()
@@ -412,7 +417,7 @@ def initialize_server_logger():
serverlog_queue = asyncio.Queue()
async def update_websocket_serverlog():
while True:
while settings.lnbits_running:
msg = await serverlog_queue.get()
await websocket_updater(super_user_hash, msg)