add check for stale PID file or old processes to gracefully handle hard container stop/starts, discussed in #144
This commit is contained in:
		
							parent
							
								
									437bb17f75
								
							
						
					
					
						commit
						b1b852d82c
					
				|  | @ -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 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue