From e11e6ffc3bc76b88b04d54d8a0eb1fac307789ad Mon Sep 17 00:00:00 2001 From: marcsello Date: Mon, 30 Mar 2020 01:26:45 +0200 Subject: [PATCH] Added some basic stuff --- Dockerfile | 26 +++++--------------------- extractor_service/main.py | 33 +++++++++++++++++++++++++++++++++ requirements.txt | 3 ++- 3 files changed, 40 insertions(+), 22 deletions(-) create mode 100644 extractor_service/main.py diff --git a/Dockerfile b/Dockerfile index 0283646..4ec0c29 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,12 @@ -# Use the official lightweight Python image. -# https://hub.docker.com/_/python FROM python:3.8-slim -# Copy local code to the container image. -ENV APP_HOME /app -ENV PIP_NO_CACHE_DIR=true +ADD extractor_service requirements.txt /extractor_service/ +WORKDIR /extractor_service/ -# Set timezone +ENV PIP_NO_CACHE_DIR=true ENV TZ Europe/Budapest RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone -WORKDIR $APP_HOME +RUN pip3 install -r requirements.txt -ARG RELEASE_ID -ENV RELEASE_ID ${RELEASE_ID:-""} - -#Copy requirements to install -COPY requirements.txt ./ - -# Install production dependencies. -RUN pip install -r requirements.txt - -COPY ./src ./src - -EXPOSE 8080 - -ENTRYPOINT ["gunicorn", "-b", "0.0.0.0:8080", "--workers", "1", "--threads", "8", "app:app"] +ENTRYPOINT ["python3","main.py"] diff --git a/extractor_service/main.py b/extractor_service/main.py new file mode 100644 index 0000000..9d8161a --- /dev/null +++ b/extractor_service/main.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +import logging +import os +import sys +import pika + + +def message_callback(ch, method, properties, body): + pass + + +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) + + connection = pika.BlockingConnection(pika.connection.URLParameters(os.environ['PIKA_URL'])) + channel = connection.channel() + channel.exchange_declare(exchange='wave-extract', exchange_type='fanout') + + queue_declare_result = channel.queue_declare(queue='', exclusive=True) + queue_name = queue_declare_result.method.queue + + channel.queue_bind(exchange='wave-extract', queue=queue_name) + channel.basic_consume(queue=queue_name, on_message_callback=message_callback, auto_ack=True) + + try: + channel.start_consuming() + except KeyboardInterrupt: + channel.stop_consuming() + + +if __name__ == '__main__': + main() diff --git a/requirements.txt b/requirements.txt index 3e4cee2..4c1fdcf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ sentry_sdk -gunicorn \ No newline at end of file +pika +requests \ No newline at end of file