我有两个简单的 WSGI 应用程序在测试开发服务器上运行mod_wsgi
。这台机器上apache2
没有mod_python
。
WSGI配置如下
WSGIDaemonProcess tops stack-size=524288 maximum-requests=5
WSGIScriptAlias /tops /home/ubuntu/tops-cloud/tops.wsgi
<Directory /home/ubuntu/tops-cloud>
WSGIProcessGroup tops
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
WSGIDaemonProcess flaskal maximum-requests=5
WSGIScriptAlias /c14 /home/ubuntu/c14/flaskal/flaskal.wsgi
<Directory /home/ubuntu/c14/flaskal>
WSGIProcessGroup flaskal
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
如果我对配置进行了更改(例如,最大请求数等),则需要重新启动 Web 服务器,因此我希望简单操作sudo service apache2 restart
能够满足我的需要。
相反,它永远不会结束“等待”,就像这样:
$ sudo service apache2 restart
* Restarting web server apache2
... waiting ..................................................
直到我执行CTRL-C
。此时,恢复正在运行的服务器的唯一方法是终止进程并重新启动它,不太方便。命令也是如此stop
。
重启失败后,“调试”级别的错误日志显示以下几行
[Wed Nov 14 21:55:19 2012] [notice] caught SIGTERM, shutting down
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=9047): Shutdown requested 'tops'.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=9047): Stopping process 'tops'.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=9047): Destroying interpreters.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=9047): Cleanup interpreter ''.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=9047): Terminating Python.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=8920): Shutdown requested 'flaskal'.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=8920): Stopping process 'flaskal'.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=8920): Destroying interpreters.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=8920): Cleanup interpreter ''.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=8920): Terminating Python.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=8920): Python has shutdown.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=9047): Python has shutdown.
如果我随后尝试再次重新启动(进程仍在运行),我会收到以下错误:
* Restarting web server apache2 (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.
不幸的是 Apache 错误日志没有任何内容。
当 apache2 正常运行时,两个应用程序都可以正常运行。
答案1
在某些情况下,日志条目不会写入磁盘(如果日志不存在或其权限错误)。诊断错误的最佳方法是尝试使用以下命令启动 Apache strace -Ff apachectl start
。