python 3.6更新后无法启动gunicorn.sock

时间:2017-03-27 12:28:03

标签: python django nginx gunicorn

我正在尝试使用Django + Gunicorn + Python3部署Nginx应用。在更新到python 3.6之前,一切正常。但更新后我似乎无法创建一个gunicorn袜子文件。我使用下面的脚本来运行Gunicorn。

#!/bin/bash

NAME=yogavidya                              #Name of the application (*)
DJANGODIR=/home/ytsejam/public_html/abctasarim/     # Django project directory (*)
SOCKFILE=/home/ytsejam/public_html/abctasarim/run/gunicorn.sock        # we will communicate using this unix socket (*)
USE=ytsejam                                        # the user to run as (*)
GROUP=webdata                                     # the group to run as (*)
NUM_WORKERS=1                                     # how many worker processes should Gunicorn spawn (*)
DJANGO_SETTINGS_MODULE=yogavidya.settings.base           # which settings file should Django use (*)
DJANGO_WSGI_MODULE=yogavidya.wsgi                     # WSGI module name (*)

echo "Starting $NAME as `whoami`"

# Activate the virtual environment
cd $DJANGODIR
source /usr/bin/virtualenvwrapper.sh
source /home/ytsejam/.virtualenvs/yv_dev/bin/activate

workon yv_dev
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)

exec /home/ytsejam/public_html/abctasarim/gunicorn --name=$NAME --workers=$NUM_WORKERS --env=DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE  --pythonpath /home/ytsejam/public_html/abctasarim --user ytsejam --bind=unix:/home/ytsejam/public_html/abctasarim/run/gunicorn.sock yogavidya.wsgi:application

当我检查显示运行脚本的状态服务的输出消息时,如果失败,行为会不时更改:

● yogavidya.service - Yogavidya gunicorn daemon
   Loaded: loaded (/usr/lib/systemd/system/yogavidya.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2017-03-27 13:13:36 BST; 10min ago
  Process: 14393 ExecStart=/home/ytsejam/public_html/abctasarim/gunicorn_start.sh (code=exited, status=1/FAILURE)
 Main PID: 14393 (code=exited, status=1/FAILURE)

Mar 27 13:13:36 ytsejam gunicorn_start.sh[14393]:   File "/home/ytsejam/.virtualenvs/yv_dev/lib/python3.6/site-packages/gunicorn/sock.py", line 117, in __init__
Mar 27 13:13:36 ytsejam gunicorn_start.sh[14393]:     super(UnixSocket, self).__init__(addr, conf, log, fd=fd)
Mar 27 13:13:36 ytsejam gunicorn_start.sh[14393]:   File "/home/ytsejam/.virtualenvs/yv_dev/lib/python3.6/site-packages/gunicorn/sock.py", line 32, in __init__
Mar 27 13:13:36 ytsejam gunicorn_start.sh[14393]:     self.sock = self.set_options(sock, bound=bound)
Mar 27 13:13:36 ytsejam gunicorn_start.sh[14393]:   File "/home/ytsejam/.virtualenvs/yv_dev/lib/python3.6/site-packages/gunicorn/sock.py", line 46, in set_options
Mar 27 13:13:36 ytsejam gunicorn_start.sh[14393]:     if err[0] not in (errno.ENOPROTOOPT, errno.EINVAL):
Mar 27 13:13:36 ytsejam gunicorn_start.sh[14393]: TypeError: 'OSError' object is not subscriptable
Mar 27 13:13:36 ytsejam systemd[1]: yogavidya.service: Main process exited, code=exited, status=1/FAILURE
Mar 27 13:13:36 ytsejam systemd[1]: yogavidya.service: Unit entered failed state.
Mar 27 13:13:36 ytsejam systemd[1]: yogavidya.service: Failed with result 'exit-code'.

当我尝试重新启动它时,我收到成功消息并且输出变为

yogavidya.service - Yogavidya gunicorn daemon
   Loaded: loaded (/usr/lib/systemd/system/yogavidya.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2017-03-27 13:25:55 BST; 1s ago
 Main PID: 14590 (gunicorn)
   CGroup: /system.slice/yogavidya.service
           └─14590 /home/ytsejam/.virtualenvs/yv_dev/bin/python3 /home/ytsejam/public_html/abctasarim/gunicorn --name=yogavidya --workers=1 --env=DJANGO_SETTINGS_MODULE=yogavidya.settings.base --pythonpath /home

Mar 27 13:25:55 ytsejam systemd[1]: Started Yogavidya gunicorn daemon.
Mar 27 13:25:55 ytsejam gunicorn_start.sh[14590]: Starting yogavidya as ytsejam

但我仍然无法在"run"文件夹中看到sock文件。如何修复gunicorn脚本以启动sock文件?

由于

0 个答案:

没有答案