Gunicorn graceful stopping with docker-compose

跟風遠走 提交于 2019-12-04 12:20:26

TL;DR

Add exec after CMD in your dockerfile: CMD exec gunicorn -b :8000 test:app.

Details

I had the same issue, when I ran docker exec my_running_gunicorn ps aux, I saw something like:

gunicorn     1  0.0  0.0   4336   732 ?        Ss   10:38   0:00 /bin/sh -c gunicorn -c gunicorn.conf.py vision:app
gunicorn     5  0.1  1.1  91600 22636 ?        S    10:38   0:00 /usr/local/bin/python /usr/local/bin/gunicorn -c gunicorn.conf.py vision:app
gunicorn     8  0.2  2.5 186328 52540 ?        S    10:38   0:00 /usr/local/bin/python /usr/local/bin/gunicorn -c gunicorn.conf.py vision:app

The 1 PID is not the gunicorn master, hence it didn't receive the sigterm signal.

With the exec in the Dockerfile, I now have

gunicorn     1 32.0  1.1  91472 22624 ?        Ss   10:43   0:00 /usr/local/bin/python /usr/local/bin/gunicorn -c gunicorn.conf.py vision:app
gunicorn     7 45.0  1.9 131664 39116 ?        R    10:43   0:00 /usr/local/bin/python /usr/local/bin/gunicorn -c gunicorn.conf.py vision:app

and it works.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!