From fb228475e3ff65b69bbf7cc246085c56737fd2c7 Mon Sep 17 00:00:00 2001 From: "michael.rabellino" Date: Thu, 27 Jun 2024 12:56:19 -0600 Subject: [PATCH] trying to run mock ims with gunicorn, flask is giving 401 errors --- docker/mockims/dev/Dockerfile | 21 ++++++++++++++++++- .../ims_service/src/ims_service.py | 3 +++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/docker/mockims/dev/Dockerfile b/docker/mockims/dev/Dockerfile index 0cee141..9b66aee 100644 --- a/docker/mockims/dev/Dockerfile +++ b/docker/mockims/dev/Dockerfile @@ -21,4 +21,23 @@ COPY ./python/idsse_testing/ims_service/profiles/*.json /python/profiles/ # for now. #VOLUME /python/profiles -ENTRYPOINT [ "python3", "/python/ims_service/ims_service.py" ] +# Run with flask (local only) +#ENTRYPOINT [ "python3", "/python/ims_service/ims_service.py" ] + +# Run with gunicorn +ENV PORT 5000 +ENV WORKERS 2 +ENV LOGLEVEL info + +EXPOSE $PORT + +# Create entry script to run service +RUN echo "#!/bin/sh" > /app/entry.sh && \ + echo "gunicorn --chdir /app -w \${WORKERS} \\" >> /app/entry.sh && \ + echo " -b 0.0.0.0:\${PORT} --worker-tmp-dir /dev/shm \\" >> /app/entry.sh && \ + echo " --enable-stdio-inheritance --access-logfile - --error-logfile - \\" >> /app/entry.sh && \ + echo " --access-logformat '%(h)s %(t)s \"%(r)s\" %(s)s %(b)s \"%(f)s\" \"%(a)s\" %(T)s %(M)s' \\" >> /app/entry.sh && \ + echo " --log-level \${LOGLEVEL} 'app:app' " >> /app/entry.sh && \ + chmod a+x /app/entry.sh + +ENTRYPOINT ["/app/entry.sh"] \ No newline at end of file diff --git a/python/idsse_testing/ims_service/src/ims_service.py b/python/idsse_testing/ims_service/src/ims_service.py index 622000f..779c461 100644 --- a/python/idsse_testing/ims_service/src/ims_service.py +++ b/python/idsse_testing/ims_service/src/ims_service.py @@ -28,6 +28,9 @@ @app.route('/all-events', methods=['GET']) def profiles(): + print('Received GET request for all events, with headers:', request.headers) + print(' request.args.keys are:', request.args.keys()) + logger.info('Received GET request for all events, with headers: %s', request.headers) logger.info(' request.args.keys are: %s', request.args.keys())