python - 如何测试 gunicorn 配置文件语法
问题描述
有没有办法在 ubuntu 或 python 或 gunicorn 函数中测试 gunicorn 配置文件语法是否正确。
我在用:
- 应用环境安装gunicorn 19.9.0
- 蟒蛇3.6
- Ubuntu 18.04
此刻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"
并且它不会按预期写入访问日志。
解决方案
我不知道你到底想要什么。
但是,我猜,您可能想检查配置文件是否有效。
你可以试试这个:
$ gunicorn --check-config APP_MODULE
或者
$ gunicorn --check-config config.py
当然,您需要将 WSGI 应用程序对象命名为,application
因为 gunicorn 的默认设置目标应用程序为application
.
您可以在此处找到详细的解决方案。
推荐阅读
- vb.net - 将列值添加到一行
- geometry - 距离度量不同的单位
- visual-studio - 无法使用 Visual Studio 2019 和 Azure 发布 Web 应用程序
- python - 如何在 Python 中使用输入文件(bash 命令)运行二进制可执行文件?
- python - Pytest 如何在范围“类”中包含“设置”固定装置
- azure - Azure SignalR 服务连接字符串
- python - 如何根据另一个键的值从嵌套(不总是存在的)字典列表中提取给定键的值 [Python]
- java - 我在我的 JLabel 中添加了一个 gif,但它只播放一次并且无法继续,我该如何解决?
- regex - 聊天机器人问题 - 无限递归 - Codecademy 问题
- c - C 中的静态 const char* VS const char*