Added amqp

This commit is contained in:
2021-08-19 03:25:30 +02:00
parent 5a5c510fa0
commit fdacc7a36d
6 changed files with 148 additions and 2 deletions

View File

@@ -4,9 +4,11 @@ from sentry_sdk.integrations.flask import FlaskIntegration
from flask import Flask
from werkzeug.middleware.proxy_fix import ProxyFix
import atexit
from apscheduler.schedulers.background import BackgroundScheduler
# import stuff
from utils import register_all_error_handlers, storage, register_health_checks
from utils import register_all_error_handlers, storage, register_health_checks, magic_amqp
# import views
from views import ObjectView
@@ -37,6 +39,12 @@ app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1)
# init stuff
storage.init_app(app)
magic_amqp.init_app(app)
ampq_loop_scheduler = BackgroundScheduler()
ampq_loop_scheduler.add_job(func=lambda: magic_amqp.loop(), trigger="interval", seconds=5)
atexit.register(lambda: ampq_loop_scheduler.shutdown())
# register error handlers
register_all_error_handlers(app)