add version to fastapi app and startup log (#1568)

* add version to fastapi app and startup log

* move version into settings

* remove unused dep
This commit is contained in:
dni ⚡ 2023-03-30 14:19:45 +02:00 committed by GitHub
parent 994b203a8e
commit 407a61cd29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -57,6 +57,7 @@ def create_app() -> FastAPI:
app = FastAPI(
title="LNbits API",
description="API for LNbits, the free and open source bitcoin wallet and accounts system with plugins.",
version=settings.version,
license_info={
"name": "MIT License",
"url": "https://raw.githubusercontent.com/lnbits/lnbits/main/LICENSE",
@ -305,6 +306,7 @@ def register_startup(app: FastAPI):
def log_server_info():
logger.info("Starting LNbits")
logger.info(f"Version: {settings.version}")
logger.info(f"Baseurl: {settings.lnbits_baseurl}")
logger.info(f"Host: {settings.host}")
logger.info(f"Port: {settings.port}")

View File

@ -1,4 +1,5 @@
import importlib
import importlib.metadata
import inspect
import json
import subprocess
@ -225,6 +226,7 @@ class EnvSettings(LNbitsSettings):
lnbits_path: str = Field(default=".")
lnbits_commit: str = Field(default="unknown")
super_user: str = Field(default="")
version: str = Field(default="0.0.0")
class SaaSSettings(LNbitsSettings):
@ -366,6 +368,7 @@ try:
except:
settings.lnbits_commit = "docker"
settings.version = importlib.metadata.version("lnbits")
# printing environment variable for debugging
if not settings.lnbits_admin_ui: