【问题标题】:Flask & mod_wsgi app causing ports to stop workingFlask & mod_wsgi 应用程序导致端口停止工作
【发布时间】:2013-12-01 07:11:44
【问题描述】:

我的 Flask 和 mod_wsgi 应用程序似乎正在破坏端口。每个月左右我的页面都会停止加载,并且我会收到“Google Chrome 无法连接到”消息,但将其移动到新端口可以修复它。我检查了apache日志,那里似乎没有任何问题。如果我停止 apache 监听端口并在实时版本之前使用的端口之一上运行我的开发版 Flask 应用程序,我会收到相同的“Google Chrome 无法连接到”消息。当 apache 正在监听 Netstat 显示端口正在被 apache 监听并且 lsof -i 返回一堆正在使用该端口的 apache 进程。我不确定 mod_wsgi 是否正常。如果我从 apache 中删除端口,netstat 和 lsof 都不会返回任何内容,但该端口仍然不适用于 mod_wsgi 或烧瓶。

这是我的配置文件的 mod_wsgi 部分,更改了 ip、域和用户/组

<VirtualHost 0.0.0.0:8880>
ServerName test.example.com
DocumentRoot /var/www/html

WSGIDaemonProcess dash user=user group=group threads=5

WSGIScriptAlias / /var/www/html/dash/dashboard.wsgi

<Directory /var/www/html/dash>
    WSGIProcessGroup dash
    WSGIApplicationGroup %{GLOBAL}
    Order deny,allow
    Allow from all
</Directory>

# records regular flask errors
ErrorLog /var/www/html/dash/error.log
LogLevel warn

这是我的 wsgi 文件

import os
import sys

# location of flask app
sys.path.insert(0, '/var/www/flask/dashboard')


from dashboard import app as application

# logs python errors at production.log
if not application.debug:
    import logging
    this_dir = os.path.dirname(__file__)
    log_file = os.path.join(this_dir, 'production.log')
    file_handler = logging.FileHandler(log_file)
    file_handler.setLevel(logging.WARNING)
    application.logger.addHandler(file_handler)

【问题讨论】:

  • 我们需要更多信息: 1) 您是否正在检查 apache 错误日志以及访问日志? 2) 您如何设置 mod_wsgi(即您设置 mod_wsgi 的.conf 文件的内容是什么)? 3) 你的.wsgi 文件是什么样的? 4) 如果您在发生这种情况后重新启动 apache 并 硬重新加载 Chrome 中的页面(清除缓存并重新加载),一切都会恢复吗?
  • 1) 我查看了访问日志,但我不确定要查找什么。 2 & 3)我会将这些添加到问题中。 4)我已经重启了apache并使用chrome开发者工具忽略了缓存。

标签: python apache flask mod-wsgi


【解决方案1】:

重写没有 IP 地址的虚拟主机似乎已经解决了这个问题。

<VirtualHost *:8880>

感谢找到答案的 mod_wsgi 用户组 [https://groups.google.com/forum/#!forum/modwsgi][1]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-11-12
    • 2013-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多