0

I'm learning Celery and I'd like to ask:

  1. Which is the absolute simplest way to get Celery to automatically run when Django starts in Ubuntu?. Now I manually start celery -A {prj name} worker -l INFO via the terminal.
  2. Can I make any type of configuration so Celery catches the changes in tasks.py code without the need to restart Celery? Now I ctrl+c and type celery -A {prj name} worker -l INFO every time I change something in the tasks.py code. I can foresee a problem in such approach in production if I can get Celery start automatically ==> need to restart Ubuntu instead?.

(setup: VPS, Django, Ubuntu 18.10 (no docker), no external resources, using Redis (that starts automatically)

I am aware it is a similar question to Django-Celery in production and How to ... but still it is a bit unclear as it refers to amazon and also using shell scripts, crontabs. It seems a bit peculiar that these things wouldn't work out of the box.

I give benefit to the doubt that I have misunderstood the setup of Celery.

Jaco
  • 1,564
  • 2
  • 9
  • 33

1 Answers1

0
  1. I have a deploy script that launch Celery in production. In production it's better to launch worker :
celery multi stop 5
celery multi start 5 -A {prj name} -Q:1 default -Q:2,3 QUEUE1 -Q:4,5 QUEUE2 --pidfile="%n.pid"

this will stop and launch 5 worker for different Queue

  1. Celery at launch will get the wsgi file that will use this instance of your code, it's mean you need to relaunch it to apply modification, you cannot add a watcher in production (memory cost)
MaximeK
  • 2,039
  • 1
  • 10
  • 16