This is a simple app with only 2 celery tasks for demonstrating the async tasks in celery
Django Celery App uses a number of open source projects to work properly:
- Python - is a class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible.
- Pip - is a package-management system written in Python used to install and manage software packages.
- Django - is an open source asynchronous task queue or job queue which is based on distributed message passing. While it supports scheduling, its focus is on operations in real time.
- Celery - is architectural style for distributed hypermedia systems.
- Flower - is a web based tool for monitoring and administrating Celery clusters
- Docker - is a set of platform as a service (PaaS) products that use OS-level virtualization.
$ Clone the repository and go into the project
$ Create a virtual env and activate it
$ Install the reqirements using this command `pip install requirements.txt`
$ Migrate using this command `python manage.py migrate`
$ Craete superuser using this command `python manage.py createsuperuser`
$ Run the application using this command `python manage.py runserver`
$ The app should be up and running on localhost:8000
$ The app admin should be up and running on localhost:8000/admin
$ Install docker on your local machine
$ Run redis using the following command `docker run --name my-redis-server -d -p 127.0.0.1:6379:6379 redis`
$ In new terminal run celery using `celery -A django_celery worker -l info -P solo`
$ In new terminal run flower using `celery -A django_celery flower`
$ Flower app should be up and running on localhost:5555
$ Open django shell using this command `python manage.py shell`
$ Import debug task `from django_celery.celery import debug_task`
$ Import create user task `from core.tasks import create_user`
$ Create instance of debug task `debug_task.apply_async(countdown=10)`
$ Check the result in celery terminal and flower
$ Create instance of debug task `create_user.apply_async(countdown=10)`
$ Check the result in celery terminal and flower
$ Login to admin and check if new user created
- Dockerize the application
- Use docker compose to simplify the project run and deployment