RabbitMQ + CELERY + FLOWER

Instalar rabitMQ

  • sudo apt-get install rabbitmq-server
  • sudo rabbitmqctl -q status
  • sudo rabbitmqctl stop

Instalar Flower

  • source /root/.virtualenvs/name_app/bin/activate
  • pip3 install flower

Arrancar

Configurar Celery con supervisor

  • cd /etc/supervisor/conf.d
  • touch name_app_celery.conf
  • Pegar y guadar

[program:name_app_celery]

command =/root/.virtualenvs/name_app/bin/celery worker -A name_app.celery –loglevel=INFO

directory=/var/www/name_repository/

user=root

environment=C_FORCE_ROOT=»true»

numprocs=1

stdout_logfile=/var/log/name_app/celery/access.log

stderr_logfile=/var/log/name_app/celery/error.log

autostart=true

autorestart=true

startsecs=10

; Need to wait for currently executing tasks to finish at shutdown.

; Increase this if you have very long running tasks.

stopwaitsecs = 600

stopasgroup=true

; Set Celery priority higher than default (999)

; so, if rabbitmq is supervised, it will start first.

priority=1000

  • touch name_app_celery_beat.conf
  • Pegar y guadar

[program:name_app_celery_beat]

command =/root/.virtualenvs/name_app/bin/celery beat -A name_app.celery –schedule=/tmp/celerybeat-name_app –loglevel=INFO –pidfile=/tmp/celerybeat.pid

directory=/var/www/name_repository/

user=root

environment=C_FORCE_ROOT=»true»

numprocs=1

stdout_logfile=/var/log/name_app/celery/beat_access.log

stderr_logfile=/var/log/name_app/celery/beat_error.log

autostart=true

autorestart=true

startsecs=10

; Need to wait for currently executing tasks to finish at shutdown.

; Increase this if you have very long running tasks.

stopwaitsecs = 600

stopasgroup=true

; Set Celery priority higher than default (999)

; so, if rabbitmq is supervised, it will start first.

priority=999

  • touch name_app_celery_flower.conf
  • Pegar y guadar

[program:name_app_celery_flower]

command =/root/.virtualenvs/name_app/bin/celery flower -A name_app.celery –basic_auth=usuarioflorido:Anio19_#@Flores -A name_app –address=0.0.0.0 –port=5555

directory=/var/www/name_repository/

user=root

environment=C_FORCE_ROOT=»true»

numprocs=1

stdout_logfile=/var/log/name_app/celery/flower_access.log

stderr_logfile=/var/log/name_app/celery/flower_error.log

autostart=true

autorestart=true

startsecs=10

; Need to wait for currently executing tasks to finish at shutdown.

; Increase this if you have very long running tasks.

stopwaitsecs = 600

stopasgroup=true

; Set Celery priority higher than default (999)

; so, if rabbitmq is supervised, it will start first.

priority=998

  • sudo supervisorctl update
  • sudo supervisorctl reload
  • sudo supervisorctl status

RabbitMQ

1 consola

rabbitmqctl stop

  • rabbitmqctl stop
  • rabbitmq-server

Arrancar celery

2 consola

  • source /root/.virtualenvs/name_app/bin/activate
  • cd /var/www/name_repository/
  • export C_FORCE_ROOT=»true»
  • celery -A name_app worker -l info

3 consola

  • source /root/.virtualenvs/name_app/bin/activate
  • cd /var/www/name_repository/
  • celery beat -A name_app –loglevel=INFO

Arrancar flower

4 consola

  • source /root/.virtualenvs/name_app/bin/activate
  • cd /var/www/name_repository/
  • celery flower –basic_auth=usuarioflorido:Anio19_#@Flores -A name_app –address=0.0.0.0 –port=5555