J'essaie de faire fonctionner mon serveur avec gunicorn et superviseur. a réussi à obtenir UPP avec cette commande:Mise en place de gunicorn et de superviseur pour le serveur django
$ gunicorn project.wsgi:application --bind 192.168.1.130:8000
Après cela, je fait un fichier gunicorn_init.bash. J'ai eu le code de plusieurs tutoriels. Alors devinez que c'est un moyen courant de mettre en place un gunicorn et un superviseur. Le code ressemble à ceci:
#!/bin/bash
NAME="project" # Name of the application
DJANGODIR=/home/username/projects/project # Django project directory
SOCKFILE=/home/username/.venvs/project/run/gunicorn.sock # We will communicate using this unix socket
USER=username # the user to run as
GROUP=username # the group to run as
NUM_WORKERS=1 # how many worker processes shoul Gunicorn spawn
DJANGO_SETTINGS_MODULE=project.settings.production # which settings file should Django use
DJANGO_WSGI_MODULE=project.wsgi # WSGI module name
echo "Starting $NAME as `whoami`"
# Activate the virtual environment
cd $DJANGODIR
source /home/username/.venvs/project/bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH
# Create the run directory if it doesn't exsist
RUNDIR=$(dirname $SOCKFILE)
test -d $RUNDIR || mkdir -p $RUNDIR
# Start yout Django Unicorn
# Programs meant to be run under supervisor should not daemonize themselves (do not use daemon)
exec gunicorn ${DJANGO_WSGI_UNICORN}:application \
--name $NAME \
--workers $NUM_WORKERS \
--user=$USER --group=$GROUP \
--bind=unix:$SOCKFILE \
--log-level=debug \
--log-file=-
Cela me donne seule exception est le processus de travail comme celui-ci:
[2017-10-15 12:35:37 +0200] [30218] [INFO] Starting gunicorn 19.7.1
[2017-10-15 12:35:37 +0200] [30218] [DEBUG] Arbiter booted
[2017-10-15 12:35:37 +0200] [30218] [INFO] Listening at: unix:/home/username/.venvs/project/run/gunicorn.sock (30218)
[2017-10-15 12:35:37 +0200] [30218] [INFO] Using worker: sync
[2017-10-15 12:35:37 +0200] [30223] [INFO] Booting worker with pid: 30223
[2017-10-15 12:35:37 +0200] [30223] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/home/username/.venvs/project/lib/python3.5/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
worker.init_process()
File "/home/username/.venvs/project/lib/python3.5/site-packages/gunicorn/workers/base.py", line 126, in init_process
self.load_wsgi()
File "/home/username/.venvs/project/lib/python3.5/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
self.wsgi = self.app.wsgi()
File "/home/username/.venvs/project/lib/python3.5/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/home/username/.venvs/project/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/home/username/.venvs/project/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/home/username/.venvs/project/lib/python3.5/site-packages/gunicorn/util.py", line 352, in import_app
__import__(module)
ValueError: Empty module name
[2017-10-15 12:35:37 +0200] [30223] [INFO] Worker exiting (pid: 30223)
[2017-10-15 12:35:37 +0200] [30218] [INFO] Shutting down: Master
[2017-10-15 12:35:37 +0200] [30218] [INFO] Reason: Worker failed to boot.
J'ai lu et regardé tutoriels. Je suis allé dans docs, essayant de comprendre pourquoi ça ne marche pas quand j'appelle le fichier gunicorn-bash.
Tout pointeur dans la bonne direction est très apprécié maintenant. Je suis coincé depuis pas mal de temps.
Le nombre de fois que j'ai lu le code et ne l'ai pas vu. Merci Daniel aka eagle eye – sumpen
Ne pas oublier d'accepter la réponse, comme une indication aux futurs chercheurs qu'il a résolu votre problème. –