add check for stale PID file or old processes to gracefully handle hard container stop/starts, discussed in #144

This commit is contained in:
meeb 2021-08-27 17:13:25 +10:00
parent 437bb17f75
commit b1b852d82c
1 changed files with 15 additions and 0 deletions

View File

@ -5,5 +5,20 @@ umask "$UMASK_SET"
cd /app || exit
PIDFILE=/run/app/gunicorn.pid
if [ -f "${PIDFILE}" ]
then
PID=$(cat $PIDFILE)
echo "Unexpected PID file exists at ${PIDFILE} with PID: ${PID}"
if kill -0 $PID
then
echo "Killing old gunicorn process with PID: ${PID}"
kill -9 $PID
fi
echo "Removing stale PID file: ${PIDFILE}"
rm ${PIDFILE}
fi
exec s6-setuidgid app \
/usr/local/bin/gunicorn -c /app/tubesync/gunicorn.py --capture-output tubesync.wsgi:application