Skip to content

Instantly share code, notes, and snippets.

@Gaarv
Forked from amatellanes/celery.sh
Created September 20, 2021 15:21
Show Gist options
  • Select an option

  • Save Gaarv/cd2fb9cadad5c03c209470be29b51fa8 to your computer and use it in GitHub Desktop.

Select an option

Save Gaarv/cd2fb9cadad5c03c209470be29b51fa8 to your computer and use it in GitHub Desktop.
Celery handy commands
/* Useful celery config.
app = Celery('tasks',
broker='redis://localhost:6379',
backend='redis://localhost:6379')
app.conf.update(
CELERY_TASK_RESULT_EXPIRES=3600,
CELERY_QUEUES=(
Queue('default', routing_key='tasks.#'),
Queue('hipri', routing_key='tasks.#'),
),
CELERY_ROUTES={
'tasks.tasks.add': {'queue': 'hipri'},
}
)
*/
celery -A tasks worker --loglevel=info # run the worker
celery worker --help # list command-line options available
celery multi start w1 -A proj -l info # start one or more workers in the background
celery multi restart w1 -A proj -l info # restart workers
celery multi stop w1 -A proj -l info # stop workers aynchronously
celery multi stopwait w1 -A proj -l info # stop after executing tasks are completed
celery multi start w1 -A proj -l info --pidfile=/var/run/celery/%n.pid --logfile=/var/log/celery/%n%I.log # create pid and log files in the current directory
celery -A proj inspect active # control and inspect workers at runtime
celery -A proj inspect active [email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment