使用VirtualEnv运行Gunicorn的“正在使用的连接”

我正在尝试使用Gunicorn和NGINX来build立一个开发环境。

遵循本教程: http : //ijcdigital.com/blog/djangogunicorn-and-nginx-setup/

我得到以下错误:

(WebApp)sl@cker:~/MyApps/WebApp$ gunicorn_django --bind=127.0.0.1:8001 2012-07-12 14:04:30 [5997] [INFO] Starting gunicorn 0.14.5 2012-07-12 14:04:30 [5997] [ERROR] Connection in use: ('127.0.0.1', 8001) 2012-07-12 14:04:30 [5997] [ERROR] Retrying in 1 second. 2012-07-12 14:04:31 [5997] [ERROR] Connection in use: ('127.0.0.1', 8001) 2012-07-12 14:04:31 [5997] [ERROR] Retrying in 1 second. 2012-07-12 14:04:32 [5997] [ERROR] Connection in use: ('127.0.0.1', 8001) 2012-07-12 14:04:32 [5997] [ERROR] Retrying in 1 second. 2012-07-12 14:04:33 [5997] [ERROR] Connection in use: ('127.0.0.1', 8001) 2012-07-12 14:04:33 [5997] [ERROR] Retrying in 1 second. 2012-07-12 14:04:34 [5997] [ERROR] Connection in use: ('127.0.0.1', 8001) 2012-07-12 14:04:34 [5997] [ERROR] Retrying in 1 second. 2012-07-12 14:04:35 [5997] [ERROR] Can't connect to ('127.0.0.1', 8001) 

我的webapp.sh文件如下所示:

 #!/bin/bash set -e LOGFILE=/home/sl/MyApps/WebApp/logs/webapp.log LOGDIR=$(dirname $LOGFILE) NUM_WORKERS=3 # user/group to run as USER=sl GROUP=sl ADDRESS=127.0.0.1:8001 cd /home/sl/MyApp/WebApp source /home/sl/VirtualEnvs/WebApp/bin/activate test -d $LOGDIR || mkdir -p $LOGDIR exec gunicorn_django -w $NUM_WORKERS --bind=$ADDRESS \ --user=$USER --group=$GROUP --log-level=debug \ --log-file=$LOGFILE 2>>$LOGFILE 

当浏览到http://127.0.0.1:8001/"It worked! Congratulations on your first Django-powered page." 显示正确。

我能否像这样离开,继续教程,或者我在这里做错了什么?

我知道这是一个古老的问题,但我想我有一个替代的答案。

我遇到了同样的问题。 日志会显示gunicorn尝试启动,然后显示端口的许多条目已被使用。

我意识到,我已经进入了virtualenv之前运行我的脚本。 然后再激活virtualenv。 这似乎运行脚本两次小跑。 只要我停用了我的控制台virtualenv,并让脚本处理virtualenv本身,一切按预期工作。

希望这可以帮助别人。

这听起来像你正在运行debugging服务器manage.py runserver运行服务器,然后尝试启动gunicorn将尝试使用相同的端口。