4
0

Did stuff
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-03-30 20:40:14 +02:00
parent e11e6ffc3b
commit ef67ad3ba1
3 changed files with 65 additions and 2 deletions

View File

@@ -3,16 +3,20 @@ import logging
import os
import sys
import pika
import json
from extraction import run_everything
def message_callback(ch, method, properties, body):
pass
run_everything(json.loads(body.decode('utf-8')))
def main():
logging.basicConfig(filename="", format="%(asctime)s - %(name)s [%(levelname)s]: %(message)s",
level=logging.DEBUG if '--debug' in sys.argv else logging.INFO)
logging.info("Connecting to MQ service...")
connection = pika.BlockingConnection(pika.connection.URLParameters(os.environ['PIKA_URL']))
channel = connection.channel()
channel.exchange_declare(exchange='wave-extract', exchange_type='fanout')
@@ -23,9 +27,11 @@ def main():
channel.queue_bind(exchange='wave-extract', queue=queue_name)
channel.basic_consume(queue=queue_name, on_message_callback=message_callback, auto_ack=True)
logging.info("Connection complete! Listening to messages...")
try:
channel.start_consuming()
except KeyboardInterrupt:
logging.info("SIGINT Received! Stopping stuff...")
channel.stop_consuming()