This commit is contained in:
Logan
2026-04-06 00:23:33 -04:00
parent 1a9c92b6db
commit 7de55f9885
10 changed files with 189 additions and 44 deletions
+22 -3
View File
@@ -1,11 +1,30 @@
from fastapi import FastAPI
from contextlib import asynccontextmanager
import os
import routers.op25_controller as op25_controller
from internal.logger import create_logger
from internal.liquidsoap_config_utils import generate_liquid_script
from models import IcecastConfig
# Initialize logging
LOGGER = create_logger(__name__)
# Define FastAPI app
app = FastAPI()
@asynccontextmanager
async def lifespan(app: FastAPI):
try:
config = IcecastConfig(
icecast_host=os.getenv("ICECAST_HOST", "localhost"),
icecast_port=int(os.getenv("ICECAST_PORT", "8000")),
icecast_mountpoint=os.getenv("ICECAST_MOUNT", "/radio"),
icecast_password=os.getenv("ICECAST_SOURCE_PASSWORD", "hackme"),
)
generate_liquid_script(config)
LOGGER.info("op25.liq generated from environment variables.")
except Exception as e:
LOGGER.error(f"Failed to generate op25.liq: {e}")
yield
app = FastAPI(lifespan=lifespan)
app.include_router(op25_controller.create_op25_router(), prefix="/op25")