mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-30 03:46:29 -05:00
Removing start_initialize_flags because flags are initted in perpetual_check_db_is_up_worker. Logging when flags are initialized.
This commit is contained in:
parent
d0c9bec7f4
commit
a65fa1c6fb
2 changed files with 4 additions and 10 deletions
10
main.py
10
main.py
|
|
@ -269,16 +269,6 @@ async def start_sanic_worker(app: Sanic):
|
||||||
await app.dispatch('wrolpi.periodic.check_log_level')
|
await app.dispatch('wrolpi.periodic.check_log_level')
|
||||||
|
|
||||||
|
|
||||||
@api_app.listener('after_server_start')
|
|
||||||
async def start_initialize_flags(app: Sanic):
|
|
||||||
# Only allow one child process to initialize flags.
|
|
||||||
if not app.shared_ctx.flags_initialized.is_set():
|
|
||||||
logger.info('start_initialize_flags')
|
|
||||||
app.shared_ctx.flags_initialized.set()
|
|
||||||
async with flags.db_up.wait_for():
|
|
||||||
flags.init_flags()
|
|
||||||
|
|
||||||
|
|
||||||
@api_app.signal('wrolpi.periodic.check_log_level')
|
@api_app.signal('wrolpi.periodic.check_log_level')
|
||||||
async def periodic_check_log_level():
|
async def periodic_check_log_level():
|
||||||
"""Copies global log level into this Sanic worker's logger."""
|
"""Copies global log level into this Sanic worker's logger."""
|
||||||
|
|
|
||||||
|
|
@ -192,6 +192,8 @@ def init_flags():
|
||||||
# Only need to read from once DB at startup.
|
# Only need to read from once DB at startup.
|
||||||
return
|
return
|
||||||
|
|
||||||
|
logger.debug('Initializing flags...')
|
||||||
|
|
||||||
from wrolpi.db import get_db_session
|
from wrolpi.db import get_db_session
|
||||||
with get_db_session() as session:
|
with get_db_session() as session:
|
||||||
flags: WROLPiFlag = session.query(WROLPiFlag).one_or_none()
|
flags: WROLPiFlag = session.query(WROLPiFlag).one_or_none()
|
||||||
|
|
@ -205,6 +207,8 @@ def init_flags():
|
||||||
else:
|
else:
|
||||||
outdated_zims.clear()
|
outdated_zims.clear()
|
||||||
|
|
||||||
|
logger.debug('Initialized flags')
|
||||||
|
|
||||||
|
|
||||||
@contextlib.asynccontextmanager
|
@contextlib.asynccontextmanager
|
||||||
async def wait_for_flag(flag: Flag, timeout: int = 0):
|
async def wait_for_flag(flag: Flag, timeout: int = 0):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue