Gunicorn资源使用过多:资源:处理时间

时间:2018-06-23 06:23:59

标签: nginx resources centos7 gunicorn

我正在使用Gunicorn 19.8.1,Nginx 1.12.2和Centos 7.5.1804。 每小时我都会收到来自Web服务器的四封电子邮件:

Time:         Sat Jun 23 08:00:29 2018 +0200
Account:      user
Resource:     Process Time
Exceeded:     48863 > 1800 (seconds)
Executable:   /usr/bin/python2.7
Command Line: /usr/bin/python2 /usr/bin/gunicorn --workers 3 --name user --timeout 60 --bind unix:/home/user/public_html/project/project.sock project.wsgi:application --error-logfile /var/log/gunicorn.err.log
PID:          28455 (Parent PID:28449)
Killed:       No

我想有4封电子邮件,因为我有4次处理gunicorn?

[root@server ~]# ps ax | grep gunicorn
14284 pts/0    S+     0:00 grep --color=auto gunicorn
28449 ?        Ss     0:16 /usr/bin/python2 /usr/bin/gunicorn --workers 3 --name user --timeout 60 --bind unix:/home/user/public_html/project/project.sock project.wsgi:application --error-logfile /var/log/gunicorn.err.log
28454 ?        S      0:02 /usr/bin/python2 /usr/bin/gunicorn --workers 3 --name user --timeout 60 --bind unix:/home/user/public_html/project/project.sock project.wsgi:application --error-logfile /var/log/gunicorn.err.log
28455 ?        S      0:02 /usr/bin/python2 /usr/bin/gunicorn --workers 3 --name user --timeout 60 --bind unix:/home/user/public_html/project/project.sock project.wsgi:application --error-logfile /var/log/gunicorn.err.log
28456 ?        S      0:02 /usr/bin/python2 /usr/bin/gunicorn --workers 3 --name user --timeout 60 --bind unix:/home/user/public_html/project/project.sock project.wsgi:application --error-logfile /var/log/gunicorn.err.log

我是Gunicorn和Nginx的新手,所以我真的不知道为什么会这样。我已经在gunicorn.service中添加了--timeout 60设置,希望这种过量的资源使用将停止,但是除了--timeout 60杀死并重新启动worker之外,其他一切都没有改变,只是现在正好每小时产生一次电子邮件。每60秒而不是每分钟。 这是etc/systemd/system/gunicorn.service文件的内容:

[Unit]
Description=gunicorn daemon
After=network.target

[Service]
User=user
Group=nginx
WorkingDirectory=/home/user/public_html/project
ExecStart=/usr/bin/gunicorn --workers 3 --bind unix:/home/user/public_html/project/project.sock project.wsgi:application --error-logfile /var/log/gunicorn.err.log

[Install]
WantedBy=multi-user.target

这是我在server文件中的etc/nginx/nginx.conf块:

...
server {
        listen 80;
        server_name example.net www.example.net;

        location /static/ {
            root /home/user/myproject;
        }

        location / {
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_pass http://unix:/home/user/public_html/project/project.sock;
        }
    }
...

有人可以告诉我我在做什么错吗?

0 个答案:

没有答案