Gunicorn will not bind to my application

2020-06-11 13:13发布

I have made a django web app using the default localhost, however I am trying to set it up on a server so that I can configure a postgre database and continue on without having to redo the database later on.

I am hosting the site though a digital ocean ubuntu 14 droplet. When I created the droplet I selected that it already come preconfigured for django. It uses nginx and gunicorn to host the site.

When I first created the instance of the server, a basic django app was configured to work on the given IP. And it did.

I tried cloning my project into the same directory as that project assuming it would live on the python path ('/home/project') and configured the nginx to serve up 127.0.0.1:8000 per some of the documentation I found.

I believe the issue lies in when I try to bind gunicorn. I get the following error with this input.

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

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

I am not 100% sure, but it seems as though gunicorn is not serving up anything (or not even on) at this point.

Any suggestions as to binding this application successfully?

5条回答
闹够了就滚
2楼-- · 2020-06-11 13:58

for me this work like charm :)

cd ~/myproject
gunicorn —bind 0.0.0.0:8000 myproject.wsgi:application
查看更多
淡お忘
3楼-- · 2020-06-11 14:00

I guess it should be

gunicorn GenericRestaurantSystem.wsgi:application
查看更多
We Are One
4楼-- · 2020-06-11 14:07

I had the same problem and got it to work with this:

gunicorn -b 127.0.0.1:8000 wsgi:application

I put the wsgi.py file at the same level as manage.py.

查看更多
别忘想泡老子
5楼-- · 2020-06-11 14:09

Well that's not how you refer to the WSGI file with gunicorn. See 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.

So if your wsgi.py file is in GenericRestaurantSystem/wsgi.py, your command should be

gunicorn -b 127.0.0.1:8000 GenericRestaurantSystem.wsgi:application
查看更多
Luminary・发光体
6楼-- · 2020-06-11 14:12

Create file in root you_django_name_project "main.py":

from you_django_name_project.wsgi import application
app = application

And run:

gunicorn -b 127.0.0.1:8000 main:app
查看更多
登录 后发表回答