added rabbitmq helpers and setup command

This commit is contained in:
Gardient
2021-09-22 22:13:04 +03:00
parent 80e4ddf1a8
commit b50c67ae1e
10 changed files with 98 additions and 4 deletions

View File

@@ -5,6 +5,8 @@ from flask import current_app
from flask.cli import with_appcontext
from werkzeug.exceptions import MethodNotAllowed, NotFound
import rmq_helper
from .target.models import Target
from .target_exchange.models import TargetExchange
@@ -91,3 +93,16 @@ def seed():
TargetExchange.ensure_created("")
TargetExchange.ensure_created("webhooks")
@click.command()
@with_appcontext
def setup_rabmq():
"""Set up rabbitMQ"""
for exchange in TargetExchange.query.filter(TargetExchange.name != "").all():
rmq_helper.ensure_exchange_exists(exchange.name)
for target in Target.query.join(Target.exchange).filter(TargetExchange.name == "").all():
rmq_helper.ensure_queue_exists(target.routing_key)
pass