From 6f0a362829c13908039a0d621417002daec64372 Mon Sep 17 00:00:00 2001 From: Kartik Ohri Date: Mon, 27 Nov 2023 17:23:19 +0530 Subject: [PATCH] Improve uWSGI and consul-template interactions on reloading We fixed the `bind(): Address already in use [core/socket.c line 769]` error in LB 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. --- docker/uwsgi/consul-template-uwsgi.conf | 2 +- docker/uwsgi/uwsgi.ini | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/docker/uwsgi/consul-template-uwsgi.conf b/docker/uwsgi/consul-template-uwsgi.conf index 412a0b3dd..b556ff551 100644 --- a/docker/uwsgi/consul-template-uwsgi.conf +++ b/docker/uwsgi/consul-template-uwsgi.conf @@ -3,7 +3,7 @@ template { destination = "/code/consul_config.py" } exec { - command = "uwsgi --die-on-term /etc/uwsgi/uwsgi.ini" + command = ["uwsgi", "/etc/uwsgi/uwsgi.ini"] splay = "60s" reload_signal = "SIGHUP" kill_signal = "SIGTERM" diff --git a/docker/uwsgi/uwsgi.ini b/docker/uwsgi/uwsgi.ini index 36ab3757b..d26176cc7 100644 --- a/docker/uwsgi/uwsgi.ini +++ b/docker/uwsgi/uwsgi.ini @@ -11,7 +11,6 @@ processes = 20 disable-logging = true ; increase buffer size for requests that send a lot of mbids in query params buffer-size = 8192 -; when uwsgi gets a sighup, quit completely and let runit restart us -exit-on-reload = true need-app = true -log-x-forwarded-for=true +log-x-forwarded-for = true +die-on-term = true