<p>我有一个基于这个<a href="https://github.com/jcalazan/ansible-django-stack" rel="noreferrer">https://github.com/jcalazan/ansible-django-stack</a>的ansible配置的VM,但是由于某些原因,尝试启动Gunicorn会导致以下错误:</p>
<blockquote>
<p>Can't connect to /path/to/my/gunicorn.sock </p>
</blockquote>
<p>在nginx日志文件中:</p>
<blockquote>
<p>connect() to unix:/path/to/my/gunicorn.sock failed (2: No such file or directory) while connecting to upstream</p>
</blockquote>
<p>实际上,指定目录中缺少套接字文件。我已经检查了目录的权限,它们很好。</p>
<p>这是我的gunicornúu开始脚本:</p>
<pre><code>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
</code></pre>
<p>有人能告诉我还有什么可能导致丢失的套接字文件吗?</p>
<p>谢谢</p>