首页 > 解决方案 > pstree 显示了一些 Gunicorn 工人产生了 25 个其他子 gunicorn 进程

问题描述

我们的应用程序正在使用 supervisord 来运行 gunicorn 工作者。我们不在线程模式下运行 gunicorn,而是运行 8 个工作人员。下面是主管和 gunicorn conf 文件。独角兽:

#!/bin/bash
NAME="xyz"
DIR=/app/deploy/current/xyz
USER=xyz
GROUP=users
WORKERS=8
BIND=unix:/app/run/gunicorn.sock
DJANGO_SETTINGS_MODULE=xyz.settings
DJANGO_WSGI_MODULE=xyz.wsgi
LOG_LEVEL=error
cd $DIR
source /app/deploy/current/venv/bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DIR:$PYTHONPATH
exec /app/deploy/current/venv/bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
  --name $NAME \
  --workers $WORKERS \
  --user=$USER \
  --timeout 100 \
  --group=$GROUP \
  --bind=$BIND \
  --log-level=$LOG_LEVEL \
  --log-file=- \
  --max-requests=1000 \
  --max-requests-jitter=200

导师

[xyz]
command=/usr/local/bin/be-gunicorn
user=xyz
autostart=true
autorestart=true
redirect_stderr=true
priority=998
stdout_logfile=/app/logs/gunicorn/gunicornstdout.log
stderr_logfile=/app/logs/gunicorn/gunicornstdout.log

问题是当我运行 pstree 时,它​​显示一些工人产生了 25 个其他我无法理解的 gunicorns 进程。这是因为孤儿工吗?有人可以帮助我了解这里发生了什么。在下面粘贴pstree -a 输出

  ├─supervisord /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
  │   └─gunicorn /app/deploy/current/venv/bin/gunicorn xyz.wsgi:application --name xyz --workers 8 --user=xyz --timeout 100--group=
  │       ├─gunicorn /app/deploy/current/venv/bin/gunicorn xyz.wsgi:application --name xyz --workers 8 --user=xyz --timeout 100--group=
  │       │   ├─python -c from multiprocessing.semaphore_tracker import main;main(14)
  │       │   └─25*[{gunicorn}]
  │       ├─gunicorn /app/deploy/current/venv/bin/gunicorn xyz.wsgi:application --name xyz --workers 8 --user=xyz --timeout 100--group=
  │       │   ├─python -c from multiprocessing.semaphore_tracker import main;main(14)
  │       │   └─25*[{gunicorn}]
  │       ├─gunicorn /app/deploy/current/venv/bin/gunicorn xyz.wsgi:application --name xyz --workers 8 --user=xyz --timeout 100--group=
  │       │   ├─python -c from multiprocessing.semaphore_tracker import main;main(14)
  │       │   └─25*[{gunicorn}]
  │       ├─gunicorn /app/deploy/current/venv/bin/gunicorn xyz.wsgi:application --name xyz --workers 8 --user=xyz --timeout 100--group=
  │       │   ├─python -c from multiprocessing.semaphore_tracker import main;main(14)
  │       │   └─25*[{gunicorn}]
  │       ├─gunicorn /app/deploy/current/venv/bin/gunicorn xyz.wsgi:application --name xyz --workers 8 --user=xyz --timeout 100--group=
  │       │   ├─python -c from multiprocessing.semaphore_tracker import main;main(14)
  │       │   └─25*[{gunicorn}]
  │       ├─gunicorn /app/deploy/current/venv/bin/gunicorn xyz.wsgi:application --name xyz --workers 8 --user=xyz --timeout 100--group=
  │       │   ├─python -c from multiprocessing.semaphore_tracker import main;main(14)
  │       │   └─25*[{gunicorn}]
  │       ├─gunicorn /app/deploy/current/venv/bin/gunicorn xyz.wsgi:application --name xyz --workers 8 --user=xyz --timeout 100--group=
  │       │   ├─python -c from multiprocessing.semaphore_tracker import main;main(14)
  │       │   └─25*[{gunicorn}]
  │       └─gunicorn /app/deploy/current/venv/bin/gunicorn xyz.wsgi:application --name xyz --workers 8 --user=xyz --timeout 100--group=
  │           ├─python -c from multiprocessing.semaphore_tracker import main;main(14)
  │           └─25*[{gunicorn}]

这里的25*[{gunicorn}]暗示是什么?是由于每个孩子的最大请求数还是这些是孤儿工人?

标签: pythonpython-3.xdjangogunicornpstree

解决方案


推荐阅读