Django command created to run celery (worker, beat, flower)
with one command and to automatically reboot servers after changing files
Copy the management
directory and move it to the directory of your application as shown in the diagram
Your Project Folder
│
├── <project_name_folder>
│ ├── settings.py
│ ├── wsgi.py
│ └── other files..
├── <application_name_folder>
│ ├── models.py
│ ├── views.py
│ ├── management
│ │ ├── commands
│ │ │ ├── __init__.py
│ │ │ ├── _localization.py
│ │ │ └── runcelery.py
│ │ └── __init__.py
│ └── other files..
└── other folders..
python-dotenv
- if you run on Linux must installed:
procps
python manage.py runcelery
Arguments can be passed in any order, it doesn't matter.
<celery app name>
or
<"full command to run celery worker">
-h
or --help
Show help message.
-b
or --beat
Excludes the beat server at startup.
-f
or --flower
Excludes the flower server at startup.
-d
or --debug
Displays information about successful/unsuccessful completion of processes.
-ll
or --loglevel
Defines the logging level for celery worker/beat
-lf
or --logfile
Redirects the output to the console by default to a log file for celery worker/beat
The command enclosed in quotation marks gets into the positional arguments and replaces the command to run the default celery worker.
The --beat
--flower
commands fall into the optional arguments and turn off the beat and flower of the server.
python manage.py runcelery "celery --app=${CELERY_APP} worker -E \
--hostname=worker-example@%h
--uid=nobody --gid=nogroup \
--loglevel=INFO" --beat --flower