[Fixed]-Celery periodic tasks not executing

35👍

For running periodic tasks you have to run two services: celery beat together with celery worker.

You can find more information at the bottom of following page.

0👍

Here is the docker-compose file configuration that I have set up to run celery worker and celery beat. It does the job. Make sure you change main_project_folder name in the docker-compose file below:

version: '3'

services:
  
  redis:
    image: "redis:latest"
    ports:
      - "6379:6379"

  worker:
    build:
      context: .
      dockerfile: Dockerfile
    image: madefire/chordtest
    command: bash -c "celery -A main_project_folder_name worker -l INFO"
    environment:
      - BROKER_URL=redis://redis:6379/0
      - RESULT_BACKEND=redis://redis:6379/0
      - C_FORCE_ROOT=true
    volumes:
      - ./:/app/
    depends_on:
      - redis

  celery_beat:
    build:
      context: .
      dockerfile: Dockerfile
    image: madefire/chordtest
    command: bash -c "celery -A main_project_folder_name beat"
    environment:
      - BROKER_URL=redis://redis:6379/0
      - RESULT_BACKEND=redis://redis:6379/0
      - C_FORCE_ROOT=true
    volumes:
      - ./:/app/
    depends_on:
      - redis

Leave a comment