aboutsummaryrefslogtreecommitdiff
path: root/inventory-service/app/main.py
diff options
context:
space:
mode:
authoralex <[email protected]>2026-07-17 18:16:35 +0200
committeralex <[email protected]>2026-07-17 18:16:35 +0200
commit8e796c9cfcd65f6225a6ae3ec2a4419f265b0ebc (patch)
tree1bf90385144be2e9f350c31da553b1ac306ee60b /inventory-service/app/main.py
parent5f6918db393ed78dd8f038e9e5f1ea85f811dc52 (diff)
downloadorder-inventory-system-main.tar.xz
order-inventory-system-main.zip
inventory-service initHEADmain
Diffstat (limited to 'inventory-service/app/main.py')
-rw-r--r--inventory-service/app/main.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/inventory-service/app/main.py b/inventory-service/app/main.py
new file mode 100644
index 0000000..81efdd2
--- /dev/null
+++ b/inventory-service/app/main.py
@@ -0,0 +1,33 @@
+import threading
+import uvicorn
+from fastapi import FastAPI
+from app.api.v1.api import api_router
+from app.core.config import settings
+from app.kafka_consumer import start_consumer_loop
+
+app = FastAPI(title=settings.PROJECT_NAME)
+
+app.include_router(api_router, prefix="/api/v1")
+
+
[email protected]_event("startup")
+def startup_event():
+ """
+ On startup, launch the Kafka consumer in a daemon background thread
+ so the event loop and the HTTP server run concurrently.
+ """
+ consumer_thread = threading.Thread(
+ target=start_consumer_loop,
+ daemon=True,
+ name="kafka-consumer",
+ )
+ consumer_thread.start()
+
+
+def health_check():
+ return {"status": "working"}
+
+
+if __name__ == "__main__":
+ uvicorn.run("app.main:app", host="127.0.0.1", port=8001, reload=True)