port matrix-ops-bot to uv and nix flake module
This commit is contained in:
parent
c13d5fc536
commit
3a042155af
17 changed files with 2402 additions and 3476 deletions
|
|
@ -36,7 +36,7 @@ async def matrix_main(matrix_client: MatrixClient) -> None:
|
|||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI) -> AsyncIterator[None]:
|
||||
config_fname = os.environ.get("BOT_CONFIG_FILE", "config.yaml")
|
||||
config_fname = os.environ.get("BOT_CONFIG_FILE", "config.json")
|
||||
bot_settings = load_config(config_fname)
|
||||
c = MatrixClient(settings=bot_settings.matrix, join_rooms=bot_settings.get_rooms())
|
||||
app.state.matrix_client = c
|
||||
|
|
@ -46,7 +46,7 @@ async def lifespan(app: FastAPI) -> AsyncIterator[None]:
|
|||
await app.state.matrix_client.shutdown()
|
||||
|
||||
|
||||
start_http_server(9000)
|
||||
# start_http_server(9000)
|
||||
app = FastAPI(lifespan=lifespan)
|
||||
instrumentator = Instrumentator().instrument(app)
|
||||
bearer_security = HTTPBearer(auto_error=False)
|
||||
|
|
@ -173,11 +173,13 @@ async def webhook_handler(
|
|||
|
||||
|
||||
def start_dev() -> None:
|
||||
uvicorn.run("ops_bot.main:app", port=1111, host="127.0.0.1", reload=True)
|
||||
uvicorn.run("ops_bot.main:app", port=1112, host="127.0.0.1", reload=True)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
uvicorn.run(app, port=1111, host="0.0.0.0") # nosec B104
|
||||
host = os.environ.get("BOT_LISTEN_HOST", "127.0.0.1")
|
||||
port = int(os.environ.get("BOT_LISTEN_PORT", "1111"))
|
||||
uvicorn.run(app, port=port, host=host) # nosec B104
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue