Celery:

Celery is a task queue with a focus on real-time processing, while also supports task scheduling. Task queues are used as mechanisms to distribute work across multiple threads or machines. A task queues input is a unit of work called a task, dedicated worker processes and constantly monitor the queue for new work to perform. Celery communicates via messages using a broker to mediate between workers and clients.To initiate a task client puts a message on the queue, then the broker delivers that message to a worker.

Note: You can get more about celery http://celery.readthedocs.org/en/latest/django/first-steps-with-django.html

To run celery in virtual environment need to type the following command in your virtual environment

Running the worker with supervisor

In production, you will want to run the worker in the background as a daemon and sometimes there may be a chance of stopping of celery worker automatically then it should be restarted automatically. To do the tasks you need to use the tools provided like supervisord.

First, you need to install supervisor in your virtualenv and generate a configuration file.

Next, just add the following section in a configuration file:

It’s a simplified version of the Celery supervisor configuration file, adapted to work with virtualenvs.

Usage

Just run supervisord in your project directory.

Running supervisor during startup or booting time

create a file /etc/init.d/supervisord and configure your actual supervisord.conf in which celery is configured in DAEMON_ARGS as follows

to run it

and to automatically schedule it, do

To Stop and Start the service

Running supervisor during startup or booting time using upstart(For Ubuntu users)

Create a new file /etc/init/supervisor.conf. Its content should look like this:

Note that we’re using the same supervisord configuration file we used before. No changes there…

We can now start and stop supervisord with the following commands

The article was originally published at MicroPyramid blog.

Python, Django, Android and IOS, reactjs, react-native, AWS, Salesforce consulting & development company