• Mémo Celery et Supervisor

  • Gestion de processus

A partir de ce tutoriel.

sudo apt-get install supervisor

Dans /etc/supervisor/conf.d/myprogram_celery.conf :

[program:myprogram]
command=/home/user/myvenv/bin/celery -A myprogram worker -l info
directory=/home/user/Desktop/myprogram
user=user 
numprocs=1
stdout_logfile=/var/log/celery/myprogram_worker.log
stderr_logfile=/var/log/celery/myprogram_worker.log
autostart=true
autorestart=true
startsecs=60
killasgroup=true
priority=998

Dans /etc/supervisor/conf.d/myprogram_beat.conf :

[program:myprogramBeat]
command=/home/user/myvenv/bin/celery -A myprogram beat -l info
directory=/home/user/myprogram
user=user
numprocs=1
stdout_logfile=/var/log/celery/myprogram_beat.log
stderr_logfile=/var/log/celery/myprogram_beat.log
autostart=true
autorestart=true
startsecs=60
priority=999

Création des fichiers de log :

$ mkdir /var/log/celery
$ touch /var/log/celery/myrogram_worker.log
$ touch /var/log/celery/myprogram_beat.log

Relancer la configuration :

$ sudo supervisorctl reread
$ sudo supervisorctl update

Marche/arrêt/vérification du programme :

$ sudo supervisorctl stop myprogram
$ sudo supervisorctl start myprogram
$ sudo supervisorctl status myprogram

Il est possible d'utiliser l'interface de commande de supervisorctl :

$ supervisorctl
$ tail -f myprogram
$ stop myprogram
$ restart myprogram


26 novembre 2018 15:55