Reputation: 2277
I am trying to make a gunicorn bash executable file to run django server but getting error - gunicorn: error: argument --error-logfile/--log-file: expected one argument
.
Its working fine with - gunicorn bekaim_pre_registration.wsgi:application --bind 0.0.0.0:8001
but getting error with bash file.
Here is my - gunicorn_start.bash
#!/bin/bash
NAME="django_app" # Name of the application
DJANGODIR=/home/ubuntu/bekaim_pre_registration # Django project directory
SOCKFILE=/home/ubuntu/django_env/run/gunicorn.sock # we will communicte using this unix socket
USER=ubuntu # the user to run as
GROUP=ubuntu # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=bekaim_pre_registration.settings # which settings file should Django use
DJANGO_WSGI_MODULE=bekaim_pre_registration.wsgi # WSGI module name
echo "Starting $NAME as `whoami`"
# Activate the virtual environment
cd $DJANGODIR
source /home/ubuntu/django_env/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 not use --daemon)
exec gunicorn ${DJANGO_WSGI_MODULE}:application \
--name $NAME \
--workers $NUM_WORKERS \
--user=$USER --group=$GROUP \
--bind=unix:$SOCKFILE \
--log-level=debug \
--log-file
To make this script executable.
$ sudo chmod u+x gunicorn_start.bash
When I test - ./gunicorn_start.bash
Starting django_app as ubuntu
usage: gunicorn [OPTIONS] [APP_MODULE]
gunicorn: error: argument --error-logfile/--log-file: expected one argument
I am following this tutorial - https://jee-appy.blogspot.com/2017/01/deply-django-with-nginx.html
Anyone can help?
Upvotes: 1
Views: 4827
Reputation: 2277
Actually log-file is not defined in configuration -
#!/bin/bash
NAME="django_app" # Name of the application
DJANGODIR=/home/ubuntu/bekaim_pre_registration # Django project directory
SOCKFILE=/home/ubuntu/django_env/run/gunicorn.sock # we will communicte using this unix socket
USER=ubuntu # the user to run as
GROUP=ubuntu # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=bekaim_pre_registration.settings # which settings file should Django use
DJANGO_WSGI_MODULE=bekaim_pre_registration.wsgi # WSGI module name
echo "Starting $NAME as `whoami`"
# Activate the virtual environment
cd $DJANGODIR
source /home/ubuntu/django_env/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 not use --daemon)
exec gunicorn ${DJANGO_WSGI_MODULE}:application \
--name $NAME \
--workers $NUM_WORKERS \
--user=$USER --group=$GROUP \
--bind=unix:$SOCKFILE \
--log-level=debug \
--log-file=-
Upvotes: 1