没有这样的文件或目录:mod_wsgi:无法连接到'/var/run/apache2/wsgi.30303.0.1.sock'上的WSGI守护进程'web2py'

时间:2017-09-28 07:20:08

标签: apache2 mod-wsgi web2py

Web应用程序部署在EC2上,每天一次或两次随机出现以下错误,导致webapp无法访问一段时间。一段时间后会自动更正。

(2)No such file or directory: [client xxx.xx.xx.xxx:xxxxx] mod_wsgi (pid=xxxxx): Unable to connect to WSGI daemon process 'web2py' on '/var/run/apache2/wsgi.30303.0.1.sock'.

应用程序堆栈 的web2py mod_wsgi的 的Apache2

每次错误之前的日志都不同:

[Thu Sep 28 06:25:01.528334 2017] [mpm_event:notice] [pid 30303:tid 140438078609280] AH00493: SIGUSR1 received.  Doing graceful restart
[Thu Sep 28 06:25:02.318551 2017] [ssl:warn] [pid 30303:tid 140438078609280] AH01906: ip-172-31-0-91.eu-west-1.compute.internal:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Thu Sep 28 06:25:02.318574 2017] [ssl:warn] [pid 30303:tid 140438078609280] AH01909: ip-172-31-0-91.eu-west-1.compute.internal:443:0 server certificate does NOT include an ID which matches the server name
[Thu Sep 28 06:25:02.318664 2017] [wsgi:warn] [pid 30303:tid 140438078609280] mod_wsgi: Compiled for Python/2.7.11.
[Thu Sep 28 06:25:02.318669 2017] [wsgi:warn] [pid 30303:tid 140438078609280] mod_wsgi: Runtime using Python/2.7.12.
[Thu Sep 28 06:25:02.319205 2017] [mpm_event:notice] [pid 30303:tid 140438078609280] AH00489: Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g mod_wsgi/4.3.0 Python/2.7.12 configured -- resuming normal operations
[Thu Sep 28 06:25:02.319225 2017] [core:notice] [pid 30303:tid 140438078609280] AH00094: Command line: '/usr/sbin/apache2'
[Thu Sep 28 06:25:09.327495 2017] [mpm_event:error] [pid 30303:tid 140438078609280] AH00485: scoreboard is full, not at MaxRequestWorkers
[Thu Sep 28 06:28:39.560285 2017] [mpm_event:error] [pid 30303:tid 140438078609280] AH00485: scoreboard is full, not at MaxRequestWorkers
[Thu Sep 28 06:45:27.583870 2017] [wsgi:error] [pid 30307:tid 140437629064960] (2)No such file or directory: [client 172.31.32.163:24210] mod_wsgi (pid=30307): Unable to connect to WSGI daemon process 'web2py' on '/var/run/apache2/wsgi.30303.0.1.sock'.
[Thu Sep 28 06:49:14.503732 2017] [wsgi:error] [pid 30307:tid 140437603886848] (2)No such file or directory: [client 172.31.14.173:37726] mod_wsgi (pid=30307): Unable to connect to WSGI daemon process 'web2py' on '/var/run/apache2/wsgi.30303.0.1.sock'.

如果需要更多信息,请与我们联系。

1 个答案:

答案 0 :(得分:4)

这是因为当HTTP客户端使用保持活动连接并通过同一连接发出多个请求时,正常重启Apache。

问题在于Apache管理mod_wsgi守护程序进程的方式意味着即使是正常重启也会立即关闭它们。与此同时,最初接受请求的Apache子工作进程和mod_wsgi守护程序进程的代理将继续运行,直到所有客户端连接都断开。这意味着当保持活动连接和后续请求通过相同的客户端连接需要转到WSGI应用程序时,它将失败,因为mod_wsgi守护程序进程的先前版本现在已经消失。

在这种情况下,不能允许旧的Apache子进程进程连接到新的mod_wsgi守护程序进程,因为重新启动的原因可能是配置更改并允许旧的子进程进程连接到守护进程的新实例,如果在新配置下,不允许以这种方式处理请求,则可能引入安全问题。

接受这是一种罕见的情况,出现安全问题的可能性很小。考虑mod_wsgi的一个新选项可能是合理的,因为在这种情况下连接到较新的守护程序进程是可以的,并且在任何重新启动时都不会为守护程序进程旋转侦听器套接字。

这种情况一直都是已知的(10年),但是在GitHub上针对mod_wsgi创建了一个问题来考虑这样的选项。