Gunicorn:127.0.0.1正在使用中

时间:2013-11-02 13:37:26

标签: python django gunicorn

我正在尝试将Django与virtualenv一起使用。我实际上让Django hello world网页显示为127.0.0.1:8001。后来我不得不做一些小的调整,现在当我再次尝试启动它时,它给了我这个错误(我从之前的工作枪声会话ctrl-Z所以我认为不是因为那个)。

    user myenv # /opt/myenv/bin/gunicorn -c /opt/myenv/gunicorn_config.py myProject.wsgi
2013-11-02 08:26:37 [27880] [INFO] Starting gunicorn 18.0
2013-11-02 08:26:37 [27880] [ERROR] Connection in use: ('127.0.0.1', 8001)
2013-11-02 08:26:37 [27880] [ERROR] Retrying in 1 second.
2013-11-02 08:26:38 [27880] [ERROR] Connection in use: ('127.0.0.1', 8001)
2013-11-02 08:26:38 [27880] [ERROR] Retrying in 1 second.
2013-11-02 08:26:39 [27880] [ERROR] Connection in use: ('127.0.0.1', 8001)
2013-11-02 08:26:39 [27880] [ERROR] Retrying in 1 second.
^C2013-11-02 08:26:40 [27880] [ERROR] Connection in use: ('127.0.0.1', 8001)
2013-11-02 08:26:40 [27880] [ERROR] Retrying in 1 second.
2013-11-02 08:26:41 [27880] [ERROR] Connection in use: ('127.0.0.1', 8001)
2013-11-02 08:26:41 [27880] [ERROR] Retrying in 1 second.
2013-11-02 08:26:42 [27880] [ERROR] Can't connect to ('127.0.0.1', 8001)
user myenv # 

我最近使用的其他命令包括:​​

python manage.py syncdb
python manage.py startapp polls

我做了'killall python'以确保它们不是原因。

gunicorn_config.py:

command = '/opt/myenv/bin/gunicorn'
pythonpath = '/opt/myenv/myProject
workers = 1
user = 'tim'

myProject.wsgi:

import os

# os.environ["DJANGO_SETTINGS_MODULE"] = "myProject.settings"
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myProject.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

1 个答案:

答案 0 :(得分:3)

ctrl+z暂停该过程,但不会关闭它。因此,它不会释放其端口。您可以使用fg恢复该流程,然后使用ctrl+c正确关闭该流程。