gunicorn没有启动工人

时间:2014-06-14 17:44:54

标签: django gunicorn

当我运行此命令时

[jenia@arch app]../bin/gunicorn zones.wsgi:application --bind localht:8000

gunicorn服务器运行在localhost:8000。它不会像我认为的那样将任何内容返回到控制台。只是静静地跑。

当我在bin/gunicorn_start中运行我的脚本时,服务器仍然以静默方式运行并具有奇怪的行为。如果我输入django无法解析的地址,则会向我internal server error提供该地址。没有堆栈跟踪没有任何东西。

这是bin / gunicorn_start脚本:

#!/bin/bash

NAME="hello_app" # Name of the application
DJANGODIR=/srv/http/proj05/app # Django project directory
SOCKFILE=/srv/http/proj05/app/run/gunicorn.sock # we will communicte using this unix socket
USER=jenia # the user to run as
GROUP=jenia # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=zones.settings # which settings file should Django use
DJANGO_WSGI_MODULE=zones.wsgi # WSGI module name

echo "Starting $NAME as `whoami`"

# Activate the virtual environment
cd $DJANGODIR
source activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH


# Create the run directory if it doesn't exist
RUNDIR=$(dirname $SOCKFILE)
test -d $RUNDIR || mkdir -p $RUNDIR



# Start your Django Unicorn
# Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon)
echo "about to exec exec is" $DJANGO_WSGI_MODULE
exec ../bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
--name $NAME \
--workers $NUM_WORKERS \
--user=$USER --group=$GROUP \
--log-level=debug \
--bind=unix:$SOCKFILE

顺便说一句,我通过以下方式创造了一个虚拟世界:

cd proj05
virtualenv .
source bin/activate
pip install django
pip install gunicorn
...

有谁能告诉我如何让gunicorn输出调试信息而不仅仅是internal server error

提前致谢。

3 个答案:

答案 0 :(得分:20)

现在默认情况下,gunicorn不会返回控制台。使用选项--log-file=-来执行此操作。

此错误也应在https://github.com/benoitc/gunicorn/issues/785中修复。

明天我会发布。

答案 1 :(得分:8)

我能够通过恢复到Gunicorn 18.0.0来解决这个问题。

pip uninstall gunicorn
pip install gunicorn==18.0.0

不是理想的解决方案。也许值得为此问题制作一张错误票。我担心的是我无法确定问题是什么......所以我该如何制作一张合适的错误票?哈哈

答案 2 :(得分:5)

您应该使用--log-file=-选项

有关详细信息,请参阅:http://gunicorn-docs.readthedocs.org/en/latest/faq.html#why-i-don-t-see-any-logs-in-the-console

相关问题