move kafka to threadings and setup database connection

This commit is contained in:
2025-04-15 14:16:36 +01:00
parent 46ba285b99
commit 9b36592fce
6 changed files with 48 additions and 10 deletions
+9 -9
View File
@@ -1,17 +1,13 @@
import threading
from app import create_app
from app.integrations import KafkaIntegration
from app.config import settings
from app.utils.logger import logger
app = create_app()
kafka = KafkaIntegration()
if __name__ != "__main__":
#Expose WSGI app instance for Gunicorn
wsgi_app = app
kafka = KafkaIntegration()
def start_kafka_consumer():
logger.info("Starting Kafka consumer...")
while True:
try:
@@ -28,8 +24,12 @@ if __name__ != "__main__":
except Exception as e:
logger.error(f"Error while receiving message: {e}")
raise
if __name__ != "__main__":
# Expose WSGI app instance for Gunicorn
# wsgi_app = app
wsgi_app = app
# Start kafka in a thread
# threading.Thread(target=start_kafka_consumer, daemon=True).start()