Skip to content

Commit

Permalink
Merge pull request #3035 from metabrainz/uwsgi-conf
Browse files Browse the repository at this point in the history
LB-1676: Kill lingering uWSGI processes on restart
  • Loading branch information
MonkeyDo authored Nov 19, 2024
2 parents ea3d16a + 23c2fc0 commit 537e7f6
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 1 deletion.
1 change: 0 additions & 1 deletion docker/consul-template.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
template {
source = "/code/listenbrainz/consul_config.py.ctmpl"
destination = "/code/listenbrainz/listenbrainz/config.py"
command = "sv hup uwsgi"
}
template {
source = "/code/listenbrainz/admin/config.sh.ctmpl"
Expand Down
12 changes: 12 additions & 0 deletions docker/services/api_compat/api_compat.service
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
#!/bin/bash

set -x

UWSGI_PID_FILE=/tmp/uwsgi-api-compat.pid
if [ -e "$UWSGI_PID_FILE" ]; then
UWSGI_PID=`cat "$UWSGI_PID_FILE"`
echo "Previous uwsgi master process pid file detected, killing process $UWSGI_PID..."
kill -TERM "$UWSGI_PID"
sleep 4
fi

# wait for syslog to start up
sleep 1

exec run-consul-template -config /etc/consul-template-api-compat.conf
1 change: 1 addition & 0 deletions docker/services/api_compat/uwsgi-api-compat.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ disable-logging = true
; quit uwsgi if the python app fails to load
need-app = true
die-on-term = true
safe-pidfile = /tmp/uwsgi-api-compat.pid
12 changes: 12 additions & 0 deletions docker/services/labs_api/labs_api.service
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
#!/bin/bash

set -x

UWSGI_PID_FILE=/tmp/uwsgi-labs-api.pid
if [ -e "$UWSGI_PID_FILE" ]; then
UWSGI_PID=`cat "$UWSGI_PID_FILE"`
echo "Previous uwsgi master process pid file detected, killing process $UWSGI_PID..."
kill -TERM "$UWSGI_PID"
sleep 4
fi

# wait for syslog to start up
sleep 1

exec run-consul-template -config /etc/consul-template-labs-api.conf
1 change: 1 addition & 0 deletions docker/services/labs_api/uwsgi-labs-api.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ need-app = true
; increase buffer size for requests that send a lot of mbids in query params
buffer-size = 8192
die-on-term = true
safe-pidfile = /tmp/uwsgi-labs-api.pid
1 change: 1 addition & 0 deletions docker/services/uwsgi/consul-template-uwsgi.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
template {
source = "/etc/uwsgi/uwsgi.ini.ctmpl"
destination = "/etc/uwsgi/uwsgi.ini"
command = "sv hup uwsgi"
}

template {
Expand Down
1 change: 1 addition & 0 deletions docker/services/uwsgi/uwsgi.ini.ctmpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ need-app = true
; increase buffer size for requests that send a lot of mbids in query params
buffer-size = 8192
die-on-term = true
safe-pidfile = /tmp/uwsgi.pid
12 changes: 12 additions & 0 deletions docker/services/uwsgi/uwsgi.service
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
#!/bin/bash

set -x

UWSGI_PID_FILE=/tmp/uwsgi.pid
if [ -e "$UWSGI_PID_FILE" ]; then
UWSGI_PID=`cat "$UWSGI_PID_FILE"`
echo "Previous uwsgi master process pid file detected, killing process $UWSGI_PID..."
kill -TERM "$UWSGI_PID"
sleep 4
fi

# wait for syslog to start up
sleep 1

exec run-consul-template -config /etc/consul-template-uwsgi.conf

0 comments on commit 537e7f6

Please sign in to comment.