Skip to content

Commit

Permalink
task(observability): Enable UWSGI status endpoint and metrics for mul…
Browse files Browse the repository at this point in the history
…tiple workers (#301)

* task(observability): Adopt new base image

* enable uwsgi status endpoint to export metrics through sidecar later

* adding config to track metrics for different worker pids

* correct name of the folder

* add logrotate (it was supposed to be available on the parent img)
  • Loading branch information
Marcelo R Costa authored Jan 12, 2021
1 parent 83bf85e commit 3c9ef24
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# To run: docker run -v /path/to/wsgi.py:/var/www/indexd/wsgi.py --name=indexd -p 81:80 indexd
# To check running container: docker exec -it indexd /bin/bash

FROM quay.io/cdis/python-nginx:pybase3-1.4.1
FROM quay.io/cdis/python-nginx:pybase3-1.4.2


ENV appname=indexd

RUN apk update \
&& apk add postgresql-libs postgresql-dev libffi-dev libressl-dev \
&& apk add linux-headers musl-dev gcc \
&& apk add curl bash git vim
&& apk add curl bash git vim logrotate

COPY . /$appname
COPY ./deployment/uwsgi/uwsgi.ini /etc/uwsgi/uwsgi.ini
COPY ./deployment/uwsgi/wsgi.py /$appname/wsgi.py
COPY clear_prometheus_multiproc /$appname/clear_prometheus_multiproc
WORKDIR /$appname

RUN python -m pip install --upgrade pip \
Expand Down
7 changes: 7 additions & 0 deletions clear_prometheus_multiproc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -ex

rm -Rf $1
mkdir $1
chmod 755 $1
chown 100:101 $1
4 changes: 4 additions & 0 deletions deployment/uwsgi/uwsgi.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ wsgi-file=/indexd/wsgi.py
plugins = python3
vacuum = true
pythonpath = /indexd/
stats = 127.0.0.1:9191
stats-http = true
env = prometheus_multiproc_dir=/var/tmp/uwsgi_flask_metrics
exec-asap = /indexd/clear_prometheus_multiproc /var/tmp/uwsgi_flask_metrics
# Initialize application in worker processes, not master. This prevents the
# workers from all trying to open the same database connections at startup.
lazy = true
Expand Down

0 comments on commit 3c9ef24

Please sign in to comment.