Reputation: 33585
I'm getting the error: django project not found when I try to run my bash script below, why?
This works: gunicorn wsgi:application -b 127.0.0.1:8003
This errors: bash start_gunicorn.sh
start_gunicorn.sh:
#!/bin/bash
set -e
LOGFILE=/srv/domain/logs/domain.log
ERRORFILE=/srv/domain/logs/error.log
LOGDIR=$(dirname $LOGFILE)
NUM_WORKERS=3
#The below address:port info will be used later to configure Nginx with Gunicorn
ADDRESS=127.0.0.1:8003
# user/group to run as
#USER=your_unix_user
#GROUP=your_unix_group
cd /srv/domain
test -d $LOGDIR || mkdir -p $LOGDIR
exec gunicorn_django -w $NUM_WORKERS --bind=$ADDRESS \
--log-level=debug \
--log-file=$LOGFILE 2>>$LOGFILE 1>>$ERRORFILE &
Do I need to tell it where the project is? whats the setting for this?
Stack:
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/djangoapp.py", line 62, in make_default_env
raise RuntimeError("django project not found")
RuntimeError: django project not found
2014-04-02 10:13:56 [1038] [INFO] Worker exiting (pid: 1038)
Traceback (most recent call last):
File "/usr/local/bin/gunicorn_django", line 9, in <module>
load_entry_point('gunicorn==18.0', 'console_scripts', 'gunicorn_django')()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/djangoapp.py", line 160, in run
DjangoApplication("%(prog)s [OPTIONS] [SETTINGS_PATH]").run()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 143, in run
Arbiter(self).run()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 203, in run
self.halt(reason=inst.reason, exit_status=inst.exit_status)
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 298, in halt
self.stop()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 341, in stop
self.reap_workers()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 452, in reap_workers
raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
ubuntu@ip-10-37-235-227:/srv/domain$ sudo nano start_gunicorn.sh
Project Folder Example: Ubuntu
/srv/domain/manage.py
/srv/domain/wsgi.py
/srv/domain/project_folder/
/srv/domain/project_folder/apps/
/srv/domain/project_folder/core/
/srv/domain/project_folder/core/urls.py
etc
Upvotes: 0
Views: 1654
Reputation: 3535
In your bash script , you can run your django project by simply writing following script :
#!/bin/bash
gunicorn /srv/domain/wsgi.py
It will run in default port . if you want to add logging ,workers threads and custom port then u can specify with arguments of gunicorn
cmd . see Gunicorn Ref .
Now in production you don't want to run this script each time . so you can put it in /etc/init.d/
. so it will run on startup . See Ref
Upvotes: 2