Gunicorn不会绑定到我的申请

2024-06-17 09:33:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经使用默认的本地主机制作了一个django web应用程序,但是我正在尝试在服务器上设置它,这样我就可以配置postgre数据库并继续,而不必以后重做数据库。

我是通过数字海洋ubuntu 14滴托管网站。当我创建液滴时,我选择它已经为django预先配置好了。它使用nginx和gunicorn来托管站点。

当我第一次创建服务器实例时,一个基本的django应用程序被配置为在给定的IP上工作。确实如此。

我尝试将我的项目克隆到与该项目相同的目录中,假设它位于python路径('/home/project')上,并将nginx配置为根据我找到的一些文档提供127.0.0.1:8000的服务。

我相信问题就在我试图绑住古尼康的时候。我得到这个输入的以下错误。

gunicorn -b 127.0.0.1:8000 GenericRestaurantSystem/wsgi.py:application

ImportError: Failed to find application, did you mean 'program/wsgi:application'?

我不是百分之百的确定,但似乎古尼康在这一点上没有提供任何服务(甚至没有提供)。

关于成功绑定此应用程序的任何建议?


Tags: 项目django服务器web数据库应用程序wsgiapplication
3条回答

我想应该是

gunicorn GenericRestaurantSystem.wsgi:application

这不是用gunicorn引用WSGI文件的方式。见the docs

The module name can be a full dotted path. The variable name refers to a WSGI callable that should be found in the specified module.

因此,如果wsgi.py文件位于GenericRestaurantSystem/wsgi.py中,那么您的命令应该是

gunicorn -b 127.0.0.1:8000 GenericRestaurantSystem.wsgi:application

对我来说这件作品很有魅力:)

cd ~/myproject
gunicorn —bind 0.0.0.0:8000 myproject.wsgi:application

相关问题 更多 >