Start Celery worker using a bash script

Create your celery.sh file

# Create an empty file
> celery.sh

# Make it executable
chmod +x celery.sh


Add your worker details and project location:

#!/bin/bash

# Activate your current python environment
source /environment/bin/activate

# Move to your current django project
cd /wwwroot/django-project/

CELERY_LOGFILE=/wwwroot/django-project/logs/celery_`date "+%Y-%m-%d.%H-%M-%S"`.log
CELERYD_OPTS=" --loglevel=INFO --autoscale=10,5 --concurrency=8"

celery worker -A project-name -f $CELERY_LOGFILE $CELERYD_OPTS &

Don't forget that you'll need to update this script and use your own root directory and project name.

Top