move kafka to threadings and setup database connection
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user