added rabbitmq helpers and setup command
This commit is contained in:
@@ -95,3 +95,4 @@ def register_commands(app: Flask):
|
||||
app.cli.add_command(commands.clean)
|
||||
app.cli.add_command(commands.urls)
|
||||
app.cli.add_command(commands.seed)
|
||||
app.cli.add_command(commands.setup_rabmq)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -18,6 +18,7 @@ class Config(object):
|
||||
JWT_AUTH_HEADER_PREFIX = 'Token'
|
||||
APISPEC_TITLE = 'MahssageBus API'
|
||||
APISPEC_VERSION = 'v0.1'
|
||||
RABBITMQ_HOST = os.environ.get("RABBITMQ_HOST", "localhost")
|
||||
|
||||
|
||||
class ProdConfig(Config):
|
||||
|
||||
Reference in New Issue
Block a user