Using
export PWD=$DJANGODIR
you do NOT actually change your current working directory. You can easily check this in a shell by using the command pwd
after the set
. You will have to include something like
cd $DJANGODIR
into your script.
سؤال
I use a bash script to run gunicorn. It is named _run_gunicorn.sh_
#!/bin/bash
NAME=new_project
DJANGODIR=/home/flame/Projects/$NAME
SOCKFILE=/home/flame/launch/web.sock
USER=flame
GROUP=flame
DJANGO_SETTINGS_MODULE=$NAME.settings
DJANGO_WSGI_MODULE=$NAME.wsgi
# export PWD=$DJANGODIR # still not work if I uncomment THIS LINE
RUNDIR=$(dirname $SOCKFILE)
test -d $RUNDIR || mkdir -p $RUNDIR
gunicorn ${DJANGO_WSGI_MODULE}:application \
--name $NAME \
--workers 7 \
--user=$USER --group=$GROUP \
--log-level=debug \
--bind=unix:$SOCKFILE
If I run from the project dir:
[/home/flame/Projects/new_project]$ bash run_gunicorn.sh
It works well. But if
[~]$ bash Projects/new_project/run_gunicorn.sh
it raises errors:
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
I guess it is about current working directory. So I change the add export PWD=$DJANGODIR
before gunicorn run. But the error remains.
Is it about some python related environment variables? Or what's the problem?
المحلول
Using
export PWD=$DJANGODIR
you do NOT actually change your current working directory. You can easily check this in a shell by using the command pwd
after the set
. You will have to include something like
cd $DJANGODIR
into your script.