mod_wsgi多个进程导致活动删除的锁文件

时间:2018-02-11 07:30:13

标签: linux apache mod-wsgi

我使用mod_wsgi lib(版本:4.2.5-1.1)生成一个具有多个进程的API服务器,以便API服务器可以提供负载平衡,这里是wsgi配置beblow:

LoadModule wsgi_module /usr/lib64/httpd/modules/mod_wsgi.so
ServerName localhost
WSGIPythonPath /opt/cloud/services/test/venv/lib/python2.7/site-packages
WSGISocketPrefix /var/run/wsgi
<VirtualHost *:8777>
    WSGIDaemonProcess test-api user=openstack group=openstack processes=3 threads=2 maximum-requests=5000 shutdown-timeout=30
    WSGIScriptAlias / /var/www/test/app.wsgi
    WSGIProcessGroup test-api
    WSGIApplicationGroup %{GLOBAL}

    ErrorLog /var/log/test-apache24.log
    LogLevel warn

    <Directory /var/www/test>
        Require all granted
    </Directory>
    LimitRequestLine 80000
    LimitRequestFieldSize 80000
    <IfModule mod_ssl.c>
        SSLEngine on
        SSLProtocol TLSv1.2
        SSLCipherSuite E****************************************
        SSLCertificateFile /etc/xxxxxxx/server-cert/test.crt
        SSLCertificateKeyFile /etc/xxxxxx/server-cert/test_server.key
        SSLVerifyDepth 10
    </IfModule>
</VirtualHost>
Listen   196.128.8.72:8777

在此配置之后,我得到了一个预期的API服务器守护程序和子守护进程,如:

root      6344     1  0 14:31 ?        00:00:00 /usr/sbin/httpd -f /etc/apache2cei/httpd.conf
opensta+  6345  6344  0 14:31 ?        00:00:01 /usr/sbin/httpd -f /etc/apache2cei/httpd.conf
opensta+  6348  6344  0 14:31 ?        00:00:01 /usr/sbin/httpd -f /etc/apache2cei/httpd.conf
opensta+  6350  6344  0 14:31 ?        00:00:01 /usr/sbin/httpd -f /etc/apache2cei/httpd.conf
wwwrun    6351  6344  0 14:31 ?        00:00:00 /usr/sbin/httpd -f /etc/apache2cei/httpd.conf
wwwrun    6355  6344  0 14:31 ?        00:00:00 /usr/sbin/httpd -f /etc/apache2cei/httpd.conf
wwwrun    6357  6344  0 14:31 ?        00:00:00 /usr/sbin/httpd -f /etc/apache2cei/httpd.conf
wwwrun    6361  6344  0 14:31 ?        00:00:00 /usr/sbin/httpd -f /etc/apache2cei/httpd.conf
wwwrun    6364  6344  0 14:31 ?        00:00:00 /usr/sbin/httpd -f /etc/apache2cei/httpd.conf
wwwrun   32172  6344  0 14:32 ?        00:00:00 /usr/sbin/httpd -f /etc/apache2cei/httpd.conf

API服务器也可以正常工作,但我发现这些守护进程创建了一些不合理的锁定文件,其状态已被linux lsof工具删除:

:~ # lsof | grep deleted

httpd      6344            root    9w      REG               0,18         0 1937090182 /run/wsgi.6344.0.1.lock (deleted)
httpd      6345       openstack    9w      REG               0,18         0 1937090182 /run/wsgi.6344.0.1.lock (deleted)
httpd      6345  6378 openstack    9w      REG               0,18         0 1937090182 /run/wsgi.6344.0.1.lock (deleted)
httpd      6345  6379 openstack    9w      REG               0,18         0 1937090182 /run/wsgi.6344.0.1.lock (deleted)
httpd      6345  6380 openstack    9w      REG               0,18         0 1937090182 /run/wsgi.6344.0.1.lock (deleted)
httpd      6345  6381 openstack    9w      REG               0,18         0 1937090182 /run/wsgi.6344.0.1.lock (deleted)
httpd      6348       openstack    9wW     REG               0,18         0 1937090182 /run/wsgi.6344.0.1.lock (deleted)
httpd      6348  6382 openstack    9wW     REG               0,18         0 1937090182 /run/wsgi.6344.0.1.lock (deleted)
httpd      6348  6384 openstack    9wW     REG               0,18         0 1937090182 /run/wsgi.6344.0.1.lock (deleted)
httpd      6348  6385 openstack    9wW     REG               0,18         0 1937090182 /run/wsgi.6344.0.1.lock (deleted)
httpd      6348  6386 openstack    9wW     REG               0,18         0 1937090182 /run/wsgi.6344.0.1.lock (deleted)
httpd      6350       openstack    9w      REG               0,18         0 1937090182 /run/wsgi.6344.0.1.lock (deleted)
httpd      6350  6389 openstack    9w      REG               0,18         0 1937090182 /run/wsgi.6344.0.1.lock (deleted)
httpd      6350  6390 openstack    9w      REG               0,18         0 1937090182 /run/wsgi.6344.0.1.lock (deleted)
httpd      6350  6391 openstack    9w      REG               0,18         0 1937090182 /run/wsgi.6344.0.1.lock (deleted)
httpd      6350  6392 openstack    9w      REG               0,18         0 1937090182 /run/wsgi.6344.0.1.lock (deleted)
httpd      6351          wwwrun    9w      REG               0,18         0 1937090182 /run/wsgi.6344.0.1.lock (deleted)
httpd      6355          wwwrun    9w      REG               0,18         0 1937090182 /run/wsgi.6344.0.1.lock (deleted)
httpd      6357          wwwrun    9w      REG               0,18         0 1937090182 /run/wsgi.6344.0.1.lock (deleted)
httpd      6361          wwwrun    9w      REG               0,18         0 1937090182 /run/wsgi.6344.0.1.lock (deleted)
httpd      6364          wwwrun    9w      REG               0,18         0 1937090182 /run/wsgi.6344.0.1.lock (deleted)
httpd     32172          wwwrun    9w      REG               0,18         0 1937090182 /run/wsgi.6344.0.1.lock (deleted)

我们可以看到这些API守护程序通过最后一列中的进程ID使用了这些锁文件。

当我将wsgi conf文件中的进程num更改为1时,这些已删除的锁定文件消失了:

WSGIDaemonProcess test-api user=openstack group=openstack processes=1 threads=2 maximum-requests=5000 shutdown-timeout=30

所有人对此都有任何想法吗?

0 个答案:

没有答案