Skip to content

Commit

Permalink
docker: use uwsgi to run application by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego Rodriguez committed Jun 25, 2018
1 parent e67ded2 commit a11f7e3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
15 changes: 13 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

FROM python:3.6

ENV TERM=xterm
RUN apt-get update && \
apt-get install -y vim-tiny && \
pip install --upgrade pip
Expand All @@ -38,5 +37,17 @@ RUN if [ "${DEBUG}" = "true" ]; then pip install -r requirements-dev.txt; pip in
RUN adduser --uid 1000 --disabled-password --gecos '' reanauser && \
chown -R reanauser:reanauser /code
USER reanauser

ARG UWSGI_PROCESSES=2
ENV UWSGI_PROCESSES ${UWSGI_PROCESSES:-2}
ARG UWSGI_THREADS=2
ENV UWSGI_THREADS ${UWSGI_THREADS:-2}
ENV TERM=xterm

EXPOSE 5000
CMD ["python", "reana_job_controller/app.py"]

CMD uwsgi --module reana_job_controller.app:app \
--http-socket 0.0.0.0:5000 --master \
--processes ${UWSGI_PROCESSES} \
--threads ${UWSGI_THREADS} \
--stats /tmp/stats.socket
27 changes: 13 additions & 14 deletions reana_job_controller/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,22 +369,21 @@ def get_openapi_spec():
return jsonify(app.config['OPENAPI_SPEC'])


if __name__ == '__main__':
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(threadName)s - %(levelname)s: %(message)s'
)
app.config.from_object('reana_job_controller.config')

app.config.from_object('config')
with app.app_context():
app.config['OPENAPI_SPEC'] = build_openapi_spec()
app.config['KUBERNETES_CLIENT'] = create_api_client()

with app.app_context():
app.config['OPENAPI_SPEC'] = build_openapi_spec()
app.config['KUBERNETES_CLIENT'] = create_api_client()
job_event_reader_thread = threading.Thread(target=watch_jobs,
args=(JOB_DB,))

job_event_reader_thread = threading.Thread(target=watch_jobs,
args=(JOB_DB,))
job_event_reader_thread.start()

job_event_reader_thread.start()
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(threadName)s - %(levelname)s: %(message)s'
)

app.run(debug=True, port=5000,
host='0.0.0.0')
if __name__ == '__main__':
app.run(host='0.0.0.0')
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
'kubernetes>=6.0.0',
'marshmallow>=2.13',
'reana-commons>=0.1.0',
'uwsgi-tools>=1.1.1',
'uWSGI>=2.0.17',
'uwsgitop>=0.10',
]

packages = find_packages()
Expand Down

0 comments on commit a11f7e3

Please sign in to comment.