Skip to content

Commit

Permalink
Upgrade python, consul-template, uWSGI
Browse files Browse the repository at this point in the history
We fixed the `bind(): Address already in use [core/socket.c line 769]` error using
`exit-on-reload = true` in uWSGI configuration. However, this prevents graceful
reloading.

I did some further investigation as noted in metabrainz/artwork-redirect#46 and have
a better fix in mind now.

For the command field in exec block of consul template configuration, use array
format. This executes the command directly without spawning a shell wrapper or
setting a process group id. Both of which will interfere with forwarding signals
to the uWSGI process.

This also needs a newer version of consul-template. So upgrading to a newer
base image.
  • Loading branch information
amCap1712 committed Nov 27, 2023
1 parent be816d4 commit 4aec2f6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG PYTHON_BASE_IMAGE_VERSION=3.11-20221221
ARG PYTHON_BASE_IMAGE_VERSION=3.11-20231006
ARG NODE_VERSION=18-alpine
FROM metabrainz/python:$PYTHON_BASE_IMAGE_VERSION as metabrainz-base

Expand Down Expand Up @@ -83,7 +83,7 @@ RUN npm run build:prod
###########################################
FROM metabrainz-base as metabrainz-prod

RUN pip install --no-cache-dir uWSGI==2.0.22
RUN pip install --no-cache-dir uWSGI==2.0.23

COPY ./docker/prod/consul-template-uwsgi.conf /etc/

Expand Down
4 changes: 2 additions & 2 deletions docker/prod/consul-template-uwsgi.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ template {
}

exec {
command = "uwsgi /etc/uwsgi/uwsgi.ini"
splay = "30s"
command = ["uwsgi", "/etc/uwsgi/uwsgi.ini"]
splay = "5s"
reload_signal = "SIGHUP"
kill_signal = "SIGTERM"
kill_timeout = "30s"
Expand Down
5 changes: 3 additions & 2 deletions docker/prod/uwsgi.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[uwsgi]
uid = www-data
gid = www-data
master = true
socket = 0.0.0.0:13031
module = metabrainz
Expand All @@ -11,5 +13,4 @@ log-x-forwarded-for=true
disable-logging = true
; quit uwsgi if the python app fails to load
need-app = true
; when uwsgi gets a sighup, quit completely and let runit restart us
exit-on-reload = true
die-on-term = true

0 comments on commit 4aec2f6

Please sign in to comment.