-
Notifications
You must be signed in to change notification settings - Fork 3
/
Celery_commands.txt
72 lines (47 loc) · 1.67 KB
/
Celery_commands.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Command Reference
################
# Install celery
pip install celery
#Install RabbitMQ (Ubuntu Linux 20.04LTS)
sudo apt-get install rabbitmq-server
# Run Celery
celery -A NAMEOFINSTANCE worker --loglevel=info
celery -A HotelCenter worker --loglevel=info
[Windows OS]
celery -A HotelCenter worker -l info -E --pool=solo
# Run RabbitMQ (On Windows)
Run:
C:\Program Files\RabbitMQ Server\rabbitmq_server-3.8.6\sbin\rabbitmq-server.bat
#Run First Task
py manage.py shell
from task1.tasks import add
add.delay(2, 2)
or
add.apply_async((2, 2), countdown=5)
#Useful commands
#Show message on completion of task
logger.info("Sent review email")
###############################
Working with Flower
===============================
Windows Work Around
#####
C:\django\yt-django-celery-series-intro-install-run-task\venv\lib\site-packages\tornado\platform\asyncio.py
import sys
## source: https://github.com/veryacademy/YT-Django-Celery-Series-Part3-Schedule-Tasks/blob/c6f0402ebe27bc3ef9cfd583877f65d792e876e0/Commands.txt
################################
if sys.platform == 'win32':
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
Start Flower
#####
##flower -A HotelCenter --port=5555
celery -A HotelCenter flower --port=5566
###############################
django-celery-beat
===============================
celery -A core beat -l INFO # For deeper logs use DEBUG
celery -A core worker -B -l INFO
You can also embed beat inside the worker by enabling the workers -B option
Database scheduler
celery -A core beat -l INFO --scheduler django_celery_beat.schedulers:DatabaseScheduler
###############################