get admin settings at startup
This commit is contained in:
parent
b47ed30681
commit
4bf17c5df2
|
@ -18,6 +18,7 @@ from loguru import logger
|
||||||
import lnbits.settings
|
import lnbits.settings
|
||||||
from lnbits.core.tasks import register_task_listeners
|
from lnbits.core.tasks import register_task_listeners
|
||||||
|
|
||||||
|
from .commands import get_admin_settings
|
||||||
from .core import core_app
|
from .core import core_app
|
||||||
from .core.views.generic import core_html_routes
|
from .core.views.generic import core_html_routes
|
||||||
from .helpers import (
|
from .helpers import (
|
||||||
|
@ -42,6 +43,7 @@ def create_app(config_object="lnbits.settings") -> FastAPI:
|
||||||
"""Create application factory.
|
"""Create application factory.
|
||||||
:param config_object: The configuration object to use.
|
:param config_object: The configuration object to use.
|
||||||
"""
|
"""
|
||||||
|
<<<<<<< HEAD
|
||||||
configure_logger()
|
configure_logger()
|
||||||
|
|
||||||
app = FastAPI(
|
app = FastAPI(
|
||||||
|
@ -53,6 +55,14 @@ def create_app(config_object="lnbits.settings") -> FastAPI:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
app.mount("/static", StaticFiles(packages=[("lnbits", "static")]), name="static")
|
app.mount("/static", StaticFiles(packages=[("lnbits", "static")]), name="static")
|
||||||
|
=======
|
||||||
|
app = FastAPI()
|
||||||
|
|
||||||
|
if lnbits.settings.LNBITS_ADMIN_UI:
|
||||||
|
check_settings(app)
|
||||||
|
|
||||||
|
app.mount("/static", StaticFiles(directory="lnbits/static"), name="static")
|
||||||
|
>>>>>>> e3a1b3ae (get admin settings at startup)
|
||||||
app.mount(
|
app.mount(
|
||||||
"/core/static",
|
"/core/static",
|
||||||
StaticFiles(packages=[("lnbits.core", "static")]),
|
StaticFiles(packages=[("lnbits.core", "static")]),
|
||||||
|
@ -64,7 +74,6 @@ def create_app(config_object="lnbits.settings") -> FastAPI:
|
||||||
app.add_middleware(
|
app.add_middleware(
|
||||||
CORSMiddleware, allow_origins=origins, allow_methods=["*"], allow_headers=["*"]
|
CORSMiddleware, allow_origins=origins, allow_methods=["*"], allow_headers=["*"]
|
||||||
)
|
)
|
||||||
|
|
||||||
g().config = lnbits.settings
|
g().config = lnbits.settings
|
||||||
g().base_url = f"http://{lnbits.settings.HOST}:{lnbits.settings.PORT}"
|
g().base_url = f"http://{lnbits.settings.HOST}:{lnbits.settings.PORT}"
|
||||||
|
|
||||||
|
@ -101,6 +110,18 @@ def create_app(config_object="lnbits.settings") -> FastAPI:
|
||||||
return app
|
return app
|
||||||
|
|
||||||
|
|
||||||
|
def check_settings(app: FastAPI):
|
||||||
|
@app.on_event("startup")
|
||||||
|
async def check_settings_admin():
|
||||||
|
while True:
|
||||||
|
admin_set = await get_admin_settings()
|
||||||
|
if admin_set :
|
||||||
|
break
|
||||||
|
print("ERROR:", admin_set)
|
||||||
|
await asyncio.sleep(5)
|
||||||
|
# admin_set = await get_admin_settings()
|
||||||
|
g().admin_conf = admin_set
|
||||||
|
|
||||||
def check_funding_source(app: FastAPI) -> None:
|
def check_funding_source(app: FastAPI) -> None:
|
||||||
@app.on_event("startup")
|
@app.on_event("startup")
|
||||||
async def check_wallet_status():
|
async def check_wallet_status():
|
||||||
|
|
Loading…
Reference in New Issue
Block a user