【问题标题】:How do I use python Bottle and Gunicorn with custom settings ini file?如何将 python Bottle 和 Gunicorn 与自定义设置 ini 文件一起使用?
【发布时间】:2016-01-21 16:20:25
【问题描述】:

我正在运行一个简单的bottle 应用程序,并将gunicorn 作为网络服务器,该应用程序运行良好。我的代码:

from bottle import route, run, template

@route('/hello/<name>')
def index(name):
    return template('<b>Hello {{name}}</b>!', name=name)

bottle.run(server='gunicorn', workers="3")

问题

现在我想创建自己的gunicorn 配置文件 并将它与bottle 一起使用。我想为 gunicorn 工作者添加很多额外的功能(例如 SSL),使用配置文件是一个很好的方法。

我试过了:

bottle.run(server='gunicorn', config="settings.py.ini")
AND
bottle.run(server='gunicorn', -c="settings.py.ini")

我知道在 CLI 中可以将设置文件设置为额外选项,如下所示:

-c CONFIG, --config CONFIG
gunicorn --config="settings.py.ini"

有人知道在使用bottle gunicorn控制器时如何实现同样的功能吗?

【问题讨论】:

    标签: python settings gunicorn bottle


    【解决方案1】:

    通过采取不同的方法解决了这个问题。

    我正在使用这个问题的代码:Bottle with Gunicorn

    这使得从 CLI 使用 gunicorn 并在 gunicorn 中加载瓶子应用程序成为可能。现在我可以使用 CLI 将 gunicorn 与配置文件一起使用,它适用于瓶子。 Bottle 现在基本上是一个 Gunicorn 模块。

    【讨论】:

      猜你喜欢
      • 2012-12-06
      • 2013-04-05
      • 2011-09-22
      • 1970-01-01
      • 1970-01-01
      • 2023-03-25
      • 2023-02-01
      • 1970-01-01
      • 2017-02-01
      相关资源
      最近更新 更多