Spaces:
Sleeping
Redis Configuration for Enflow
This document explains how to configure Redis for Enflow's background task processing with Celery.
Overview
Enflow uses Redis as a message broker and result backend for Celery, which handles background tasks like:
- Processing PDF logs with OCR
- Running LLM analysis on log content
- Generating incident forms
Configuration Options
You can configure Redis connection in two ways:
Option 1: Using Individual Environment Variables
Set these three environment variables:
REDIS_HOST=your-redis-hostname-or-ip
REDIS_PORT=your-redis-port (default: 6379)
REDIS_PASSWORD=your-redis-password
Option 2: Using a Single REDIS_URL
Alternatively, set a single REDIS_URL environment variable:
REDIS_URL=redis://:{password}@{host}:{port}/0
Example:
REDIS_URL=redis://:Nsdg@2314@2314@redis-12345.example.com:6379/0
Configuration in Celery
The configuration is handled in celery_config.py, which constructs the Redis URL from individual components if they're available, or uses the provided REDIS_URL directly.
Monitoring Celery Tasks
You can monitor Celery tasks in several ways:
Celery Logs: Run the Celery worker with higher verbosity:
celery -A utils.celery_tasks.celery_app worker --loglevel=infoFlower (Optional): You can install and run Flower for a web-based monitoring UI:
pip install flower celery -A utils.celery_tasks.celery_app flowerAccess the Flower dashboard at http://localhost:5555
Celery Task Configuration
Task-specific configurations are defined in celery_config.py, including:
- Rate limits for various tasks
- Task timeouts
- Queue routing
- Serialization formats
Troubleshooting Redis Connection
If you encounter issues connecting to Redis:
- Check if your Redis server is running
- Verify the host, port, and password are correct
- Check if any firewall is blocking the Redis port
- Ensure Redis is configured to accept remote connections (if connecting remotely)
- Try connecting using the redis-cli tool:
You should receive "PONG" as the response if the connection is successfulredis-cli -h your-host -p your-port -a your-password ping
Security Considerations
- Use a strong password for Redis authentication
- Don't expose your Redis server directly to the internet
- Consider using SSL/TLS if connecting to Redis over untrusted networks
- Avoid hardcoding Redis credentials in your application code