django - 无法执行 gunicorn_start EACCES

标签 django nginx gunicorn supervisord

#!/bin/bash

NAME="trueguild"                                          # Name of the applica$
DJANGODIR=/webapps/trueguild_django/trueguild             # Django project dire$
SOCKFILE=/webapps/trueguild_django/run/gunicorn.sock      # we will communicte $
USER=trueguild                                            # the user to run as

GROUP=webapps                                             # the group to run as
NUM_WORKERS=3                                             # how many worker pro$
DJANGO_SETTINGS_MODULE=trueguild.settings                 # which settings file$
DJANGO_WSGI_MODULE=trueguild.wsgi                         # WSGI module name

echo "Starting $NAME as $NAME"

# Activate the virtual environment
cd $DJANGODIR
source ../bin/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$
exec ../bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
  --name $NAME \
  --workers $NUM_WORKERS \
 --user=$USER --group=$GROUP \
  --bind=unix:$SOCKFILE \
  --log-level=debug \
  --log-file=-

我有上面的 gunicorn_start 文件。但是当我开始使用 supervisorctl 然后它抛出这个错误
supervisor: couldn't exec /webapps/trueguild_django/bin/gunicorn_start: EACCES
supervisor: child process was not spawned

我正在使用 Django 以及 nginx 和 gunicorn。

如何使用主管启动服务器?

这是 supervisor.d conf 文件
; supervisor config file

[unix_http_server]
file=/var/run/supervisor.sock   ; (the path to the socket file)
chmod=0700                       ; sockef file mode (default 0700)

[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor            ; ('AUTO' child log dir, default $TEMP)

; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL  for a unix socket

; The [include] section can just contain the "files" setting.  This
; setting can list multiple files (separated by whitespace or
; newlines).  It can also contain wildcards.  The filenames are
; interpreted as relative to this file.  Included files *cannot*
; include files themselves.

[include]
files = /etc/supervisor/conf.d/*.conf

这是 conf.d 目录中的 trueguild.conf 文件
[program:trueguild]
command = /webapps/trueguild_django/bin/gunicorn_start                    ; Command to start app
user = trueguild                                                          ; User to run as
stdout_logfile = /webapps/trueguild_django/logs/gunicorn_supervisor.log   ; Where to write log messages
redirect_stderr = true                                                ; Save stderr in the same log
environment=LANG=en_US.UTF-8,LC_ALL=en_US.UTF-8                       ; Set UTF-8 as default encoding

最佳答案

trueguild.conf文件

添加 sh命令后...

它会像

command =sh /webapps/trueguild_django/bin/gunicorn_start

它会工作。

关于django - 无法执行 gunicorn_start EACCES,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39178923/

相关文章:

redirect - Nginx:301 从外部文件重定向

nginx - 在向上游发送请求之前,先从API获取信息

NGINX SSL 握手错误 - sslv3 警报证书已过期 :SSL alert number 45

python - Django + Gunicorn + systemd 问题

django - 在 Django 1.9 中 DEBUG 为 False 时不添加尾部斜线

python - 当没有附加对象时,如何删除 django-taggit 标签?

python - 创建 super 用户时 Django manage.pysync_db 崩溃

python - 如何识别 Bootstrap 模板中的 CSS 样式路径?

python - 在哪里检查 django 中 ClassView 中的 session ?

django - docker-compose:尝试 "up"容器时没有 gunicorn