首页 > 解决方案 > 如何测试 gunicorn 配置文件语法

问题描述

有没有办法在 ubuntu 或 python 或 gunicorn 函数中测试 gunicorn 配置文件语法是否正确。

我在用:

此刻gunicorn_config.py是这样的:

bind = '0.0.0.0:8811'
worker_class = 'sync'
loglevel = 'info'
accesslog = '/var/log/gunicorn/access_log_myapp'
errorlog = '/var/log/gunicorn/error_log_myapp'
spew = False

我想添加几行来修改日志格式并尝试不同的 gunicorn 配置文件。

我不确定如何使用 ubuntu 测试语法。

我尝试将此行添加到代码中:

acceslogformat =" JALAZBE TEST %(h)s %(l)s %(u)s %(t)s %(r)s %(s)s %(b)s %(f)s %(a)s"

并且它不会按预期写入访问日志。

标签: pythonubuntugunicorn

解决方案


我不知道你到底想要什么。

但是,我猜,您可能想检查配置文件是否有效。

你可以试试这个:

$ gunicorn --check-config APP_MODULE 或者 $ gunicorn --check-config config.py

当然,您需要将 WSGI 应用程序对象命名为,application因为 gunicorn 的默认设置目标应用程序为application.

您可以在此处找到详细的解决方案。


推荐阅读