【发布时间】:2019-09-27 12:48:58
【问题描述】:
我正在尝试使用 gunicorn 和 nginx 部署一个用 Dash 编写的应用程序。几个月前,当我知道自己在做什么时,我成功地部署了同样的应用程序。我想进行一些更新并重新部署,但现在部署将无法正常工作,即使我摆脱了所有更新。当我运行 gunicorn 时,我收到一个错误,Application must be callable。
我的项目位于folder,其中包含unified.py 文件,其中包含我的应用程序。在unified.py、app = dash.Dash(__name__, external_stylesheets=external_stylesheets) 中,我将我的 app 变量定义为 app。
我运行gunicorn folder.unified:app 并收到此错误。
但是,如果我运行from folder.unified import app,我会得到应用程序对象和所有正确的属性,没问题。
我已经尝试了 gunicorn 调用的各种变体(例如在项目文件夹中并说 gunicornunified:app, being the parent folder and usinggunicorn folder:app,gunicorn folder:unified`。我知道它可以工作,因为它以前工作过。但就我的一生而言,我无法弄清楚现在发生了什么。
我希望它的运行方式与我使用 python unified.py 使用 python 运行应用程序时类似。
有一段时间我以为我解决了它,因为我开始收到一个不同的错误(说我无法从另一个文件夹获取 .pkl 文件),但后来我在我的 unified.py 文件中注释掉了这些行并它又回到了相同的Application must be callable 错误!
【问题讨论】: