查看来自 PID 的日志 != 1



我的docker容器正在运行一个django应用程序,带有gunicorn。

root@72981b4f355e:/usr/src/app# ps -ef
UID        PID  PPID  C STIME TTY          TIME CMDq
root         1     0  0 15:32 ?        00:00:00 /usr/local/bin/python /usr/local/bin/gunicorn MyApp.wsgi:application --bind 0.0.0.0:8000 --workers 3
root         9     1  1 15:32 ?        00:00:02 /usr/local/bin/python /usr/local/bin/gunicorn MyApp.wsgi:application --bind 0.0.0.0:8000 --workers 3
root        11     1  1 15:32 ?        00:00:02 /usr/local/bin/python /usr/local/bin/gunicorn MyApp.wsgi:application --bind 0.0.0.0:8000 --workers 3
root        12     1  1 15:32 ?        00:00:02 /usr/local/bin/python /usr/local/bin/gunicorn MyApp.wsgi:application --bind 0.0.0.0:8000 --workers 3
root        21     0  0 15:35 ?        00:00:00 bash
root        28    21  0 15:35 ?        00:00:00 ps -ef
日志

不显示任何内容,因为工作线程(生成日志的工作线程(不是 PID1。

如何查看工作人员的日志?独角兽的启动方式如下:

exec gunicorn MyApp.wsgi:application 
    --bind 0.0.0.0:8000 
    --workers 3

对于访问日志,您可以添加--access-logfile -,或者如果您想查看 worker stdout,可以添加--capture-output。您可能还需要设置 PYTHONUNBUFFERED=1 env var。

来源: http://docs.gunicorn.org/en/stable/settings.html

最新更新