Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/GregaVrbancic/fastapi-celery
Minimal example utilizing fastapi and celery with RabbitMQ for task queue, Redis for celery backend and flower for monitoring the celery tasks.
https://github.com/GregaVrbancic/fastapi-celery
celery docker-compose fastapi flower python rabbitmq redis
Last synced: 13 days ago
JSON representation
Minimal example utilizing fastapi and celery with RabbitMQ for task queue, Redis for celery backend and flower for monitoring the celery tasks.
- Host: GitHub
- URL: https://github.com/GregaVrbancic/fastapi-celery
- Owner: GregaVrbancic
- Created: 2019-04-12T05:37:37.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-25T06:50:02.000Z (10 months ago)
- Last Synced: 2024-08-01T00:43:08.699Z (3 months ago)
- Topics: celery, docker-compose, fastapi, flower, python, rabbitmq, redis
- Language: Python
- Homepage:
- Size: 27.3 KB
- Stars: 508
- Watchers: 9
- Forks: 108
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-fastapi - FastAPI with Celery, RabbitMQ, and Redis - Minimal example utilizing FastAPI and Celery with RabbitMQ for task queue, Redis for Celery backend, and Flower for monitoring the Celery tasks. (Projects / Open Source Projects)
- awesome-fastapi - FastAPI with Celery, RabbitMQ, and Redis - Minimal example utilizing FastAPI and Celery with RabbitMQ for task queue, Redis for Celery backend, and Flower for monitoring the Celery tasks. (Projects / Open Source Projects)
README
# FastAPI with Celery
> Minimal example utilizing FastAPI and Celery with RabbitMQ for task queue, Redis for Celery backend and flower for monitoring the Celery tasks.
## Requirements
- Docker
- [docker-compose](https://docs.docker.com/compose/install/)## Run example
1. Run command ```docker-compose up```to start up the RabbitMQ, Redis, flower and our application/worker instances.
2. Navigate to the [http://localhost:8000/docs](http://localhost:8000/docs) and execute test API call. You can monitor the execution of the celery tasks in the console logs or navigate to the flower monitoring app at [http://localhost:5555](http://localhost:5555) (username: user, password: test).## Run application/worker without Docker?
### Requirements/dependencies
- Python >= 3.7
- [poetry](https://python-poetry.org/docs/#installation)
- RabbitMQ instance
- Redis instance> The RabbitMQ, Redis and flower services can be started with ```docker-compose -f docker-compose-services.yml up```
### Install dependencies
Execute the following command: ```poetry install --dev```
### Run FastAPI app and Celery worker app
1. Start the FastAPI web application with ```poetry run hypercorn app/main:app --reload```.
2. Start the celery worker with command ```poetry run celery worker -A app.worker.celery_worker -l info -Q test-queue -c 1```
3. Navigate to the [http://localhost:8000/docs](http://localhost:8000/docs) and execute test API call. You can monitor the execution of the celery tasks in the console logs or navigate to the flower monitoring app at [http://localhost:5555](http://localhost:5555) (username: user, password: test).