【发布时间】:2015-04-25 16:49:37
【问题描述】:
我有一个基于 https://github.com/jcalazan/ansible-django-stack 的 ansible 配置 VM,但由于某种原因尝试启动 Gunicorn 时出现以下错误:
无法连接到 /path/to/my/gunicorn.sock
在 nginx 日志文件中:
connect() to unix:/path/to/my/gunicorn.sock 在连接上游时失败(2:没有这样的文件或目录)
实际上指定目录中缺少套接字文件。我检查了目录的权限,没有问题。
这是我的 gunicorn_start 脚本:
NAME="{{ application_name }}"
DJANGODIR={{ application_path }}
SOCKFILE={{ virtualenv_path }}/run/gunicorn.sock
USER={{ gunicorn_user }}
GROUP={{ gunicorn_group }}
NUM_WORKERS={{ gunicorn_num_workers }}
# Set this to 0 for unlimited requests. During development, you might want to
# set this to 1 to automatically restart the process on each request (i.e. your
# code will be reloaded on every request).
MAX_REQUESTS={{ gunicorn_max_requests }}
echo "Starting $NAME as `whoami`"
# Activate the virtual environment.
cd $DJANGODIR
. ../../bin/activate
# Set additional environment variables.
. ../../bin/postactivate
# Create the run directory if it doesn't exist.
RUNDIR=$(dirname $SOCKFILE)
test -d $RUNDIR || mkdir -p $RUNDIR
# Programs meant to be run under supervisor should not daemonize themselves
# (do not use --daemon).
exec gunicorn \
--name $NAME \
--workers $NUM_WORKERS \
--max-requests $MAX_REQUESTS \
--user $USER --group $GROUP \
--log-level debug \
--bind unix:$SOCKFILE \
{{ application_name }}.wsgi
谁能建议还有什么可能导致丢失的套接字文件?
谢谢
【问题讨论】:
标签: python django python-2.7 nginx gunicorn