Django command to run celery (worker, beat, flower) with automatically reboot server after changing files
- The ability to run up to three servers (worker, beat, flower) simultaneously in one terminal, instead of running by default in three different terminals.
- Automatic reboot of these servers when your codebase changes.
-
Install package
pip install celery-starter
-
Add app name to
INSTALLED_APPSINSTALLED_APPS = [ 'celery_starter', ]
python manage.py runcelery
Arguments can be passed in any order, it doesn't matter.
-h or --help Show help message.
-w <cmd> or --worker <cmd> Full command line to run worker or options that extend the default command line.
-b <cmd> or --beat <cmd> Full command line to run beat or options that extend the default command line.
-f <cmd> or --flower <cmd> Full command line to run flower or options that extend the default command line.
-eb or --exclude_beat Excludes the beat server at startup.
-ef or --exclude_flower Excludes the flower server at startup.
-d or --debug Displays information about successful/unsuccessful completion of processes.
default commands:
# worker cmd
# (WARNING) Note that the default pool is solo,
# because of this, all tasks will be performed sequentially,
# to get parallelism, install one of the libraries [gevent | eventlet]
# and redefine the default pool in cmd.
celery -A <CELERY_APP> worker -E -l INFO -P solo
# beat cmd
celery -A <CELERY_APP> beat --pidfile=celerybeat.pid -l INFO
# flower cmd
celery --broker=redis://localhost:6379// flower -A <CELERY_APP> --url_prefix=flowervalid commands:
# redefining the -A and -P parameter
# and adding a new --broker parameter to the default worker command
python manage.py runcelery -w "-A <CELERY_APP> -P gevent --broker=redis://localhost:6379//"
# complete replacement of the default worker command with the passed command
python manage.py runcelery -w "celery -A <CELERY_APP> worker"We would love you to contribute to celery-starter, pull requests are very welcome! Please see CONTRIBUTING.md for more information.