From 3f3575cc18f81c02c28bceef807bcbf36d8f7e20 Mon Sep 17 00:00:00 2001 From: ajaysi Date: Mon, 6 Apr 2026 07:02:42 +0530 Subject: [PATCH] Add main block for direct uvicorn startup --- backend/app.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/backend/app.py b/backend/app.py index 668305fd..30695ffe 100644 --- a/backend/app.py +++ b/backend/app.py @@ -705,4 +705,19 @@ async def shutdown_event(): close_database() logger.info("ALwrity backend shutdown successfully") except Exception as e: - logger.error(f"Error during shutdown: {e}") + logger.error(f"Error during shutdown: {e}") + + +# Add main block to allow running directly with: python app.py +# This also helps Gunicorn work correctly +if __name__ == "__main__": + import uvicorn + port = int(os.environ.get("PORT", "10000")) + host = os.environ.get("HOST", "0.0.0.0") + + print(f"[app.py] ====================", flush=True) + print(f"[app.py] DIRECT STARTUP", flush=True) + print(f"[app.py] PORT={port}, HOST={host}", flush=True) + print(f"[app.py] ====================", flush=True) + + uvicorn.run(app, host=host, port=port)