如何测试gunicorn配置文件语法

时间:2018-08-20 09:21:43

标签: python ubuntu gunicorn

在ubuntu或python或gunicorn函数中是否有一种方法可以测试gunicorn配置文件语法是否正确。

我正在使用:

  • gunicorn 19.9.0已安装在应用程序环境中
  • python 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"

并且它将不会按预期写入acces日志。

1 个答案:

答案 0 :(得分:0)

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

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

您可以尝试以下方法:

$ gunicorn --check-config APP_MODULE 要么 $ gunicorn --check-config config.py

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

您可以找到详细的解决方案here