Skip to content

Commit ed8dc70

Browse files
committed
Moving from uwsgi to gunicorn
1 parent 12a02a2 commit ed8dc70

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

Dockerfile

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
FROM python:3.6-slim
1+
FROM tiangolo/meinheld-gunicorn-flask:python3.8-alpine3.11
22

3-
RUN apt update && apt install -y build-essential
4-
RUN groupadd --gid 1000 sonar-exporter
5-
RUN useradd --uid 1000 --gid 1000 --create-home sonar-exporter
6-
WORKDIR /home/sonar-exporter
7-
USER sonar-exporter
83
COPY . .
9-
RUN pip3.6 install -r requirements.txt
4+
RUN pip install --no-cache-dir -r requirements.txt
105

11-
EXPOSE 9119
12-
ENTRYPOINT [ "/bin/bash", "entrypoint.sh" ]
6+
RUN adduser --disabled-password 1001
7+
RUN chown -R 1001 .
8+
USER 1001

gunicorn_conf.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
loglevel = "info"
2+
errorlog = "-" # stderr
3+
accesslog = "-" # stdout
4+
worker_tmp_dir = "/dev/shm"
5+
graceful_timeout = 120
6+
timeout = 120

entrypoint.sh renamed to prestart.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,3 @@ fi
1111
if [ $SONAR_PASSWORD ]; then
1212
sed -i "s/password/$SONAR_PASSWORD/g" config.ini
1313
fi
14-
15-
# Run exporter
16-
.local/bin/uwsgi --http 0.0.0.0:${SONAR_EXPORTER_PORT:-9119} --wsgi-file main.py --callable app

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1+
# Workaround this issue: https://github.com/benoitc/gunicorn/issues/2564
2+
gunicorn==20.0.4
13
prometheus-client==0.6.0
24
requests==2.21.0
3-
uwsgi==2.0.20
45
flask==2.0.2

sonar/data/projects.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ def standardize_project_info(project, sonar):
121121
params = {'projectKey': project_key}
122122

123123
response = sonar.req.do_get(url=url, params=params)
124+
if response.status_code != 200:
125+
print(response.text)
126+
response.raise_for_status()
124127
raw_data = response.json()
125128

126129
if 'errors' in raw_data:

0 commit comments

Comments
 (0)