web-dev-qa-db-fra.com

Superviseur: ERREUR (erreur d'apparition) lorsque vous essayez de lancer gunicorn

J'ai essayé de configurer gunicorn avec un superviseur selon ces instructions . Mais quand je cours

Sudo supervisorctl reread
Sudo supervisorctl update
Sudo supervisorctl start Server-CardLearning

J'obtiens l'erreur Server-CardLearning: ERROR (spawn error).

Mon fichier de configuration est simple.

[program:Server-CardLearning]
command = gunicorn app:app -b localhost:8000
directory = /home/alexg/www/<flask project>
user = www-data

Je reçois les erreurs suivantes dans mon fichier journal.

...
...
2017-11-30 13:48:52,276 INFO gave up: Server-CardLearning entered FATAL state, too many start retries too quickly
2017-11-30 13:49:10,595 INFO spawnerr: unknown error making dispatchers for 'Server-CardLearning': ENOENT
2017-11-30 13:49:11,597 INFO spawnerr: unknown error making dispatchers for 'Server-CardLearning': ENOENT
2017-11-30 13:49:13,599 INFO spawnerr: unknown error making dispatchers for 'Server-CardLearning': ENOENT
2017-11-30 13:49:16,603 INFO spawnerr: unknown error making dispatchers for 'Server-CardLearning': ENOENT
2017-11-30 13:49:16,603 INFO gave up: Server-CardLearning entered FATAL state, too many start retries too quickly
2017-11-30 13:58:12,101 INFO spawned: 'Server-CardLearning' with pid 13725
2017-11-30 13:58:12,560 INFO exited: Server-CardLearning (exit status 3; not expected)
2017-11-30 13:58:13,563 INFO spawned: 'Server-CardLearning' with pid 13730
2017-11-30 13:58:13,982 INFO exited: Server-CardLearning (exit status 3; not expected)
2017-11-30 13:58:15,986 INFO spawned: 'Server-CardLearning' with pid 13735
2017-11-30 13:58:16,411 INFO exited: Server-CardLearning (exit status 3; not expected)
2017-11-30 13:58:19,416 INFO spawned: 'Server-CardLearning' with pid 13742
2017-11-30 13:58:19,842 INFO exited: Server-CardLearning (exit status 3; not expected)
2017-11-30 13:58:20,843 INFO gave up: Server-CardLearning entered FATAL state, too many start retries too quickly
...
...
2017-11-30 14:10:29,728 INFO spawned: 'Server-CardLearning' with pid 13901
2017-11-30 14:10:29,957 INFO exited: Server-CardLearning (exit status 2; not expected)
2017-11-30 14:10:30,961 INFO spawned: 'Server-CardLearning' with pid 13902
2017-11-30 14:10:31,193 INFO exited: Server-CardLearning (exit status 2; not expected)
2017-11-30 14:10:33,200 INFO spawned: 'Server-CardLearning' with pid 13903
2017-11-30 14:10:33,436 INFO exited: Server-CardLearning (exit status 2; not expected)
2017-11-30 14:10:36,443 INFO spawned: 'Server-CardLearning' with pid 13904
2017-11-30 14:10:36,681 INFO exited: Server-CardLearning (exit status 2; not expected)
2017-11-30 14:10:37,682 INFO gave up: Server-CardLearning entered FATAL state, too many start retries too quickly

Où vais-je mal? J'ai essayé certaines choses que j'ai vues sur le débordement de pile, mais rien ne s'est avéré pertinent pour ce problème.

9
peachykeen

La racine du problème semblait être que j'avais un problème avec app.py. J'utilisais une bibliothèque Flask que j'avais installée sur ma machine locale mais pas le serveur et pour une raison quelconque, je n'ai pas eu de grosses erreurs lorsque j'ai exécuté le serveur via flask run --Host=0.0.0.0.

J'ai compris cela en ajustant le superviseur .conf fichier situé à /etc/supervisor/conf.d/Server-CardLearning.conf

Le nouveau .conf le fichier lit:

[program:Server-CardLearning]
environment=SECRET_KEY="some_secret_key"
command=gunicorn app:app -b localhost:8000
directory=/home/alexg/www/Server-CardLearning
user=alexg
autostart=true
stderr_logfile=/var/log/supervisor/test.err.log
stdout_logfile=/var/log/supervisor/test.out.log

En ajoutant les deux fichiers journaux, j'ai pu exécuter:

cat /var/log/supervisor/test.err.log

pour voir que j'avais une bibliothèque désinstallée! ~ Halet! ~

Après avoir installé la bibliothèque, j'ai couru:

Sudo supervisorctl reread
Sudo supervisorctl update
Sudo supervisorctl start Server-CardLearning

Maintenant, si cela ne le résout pas, j'ai également trouvé que fouiller dans la console du superviseur était utile:

$ Sudo supervisorctl
supervisor> help
supervisor> status

J'espère que ça aide quelqu'un!

9
peachykeen