Spaces:
Sleeping
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: | |
| 1. **Celery Logs**: Run the Celery worker with higher verbosity: | |
| ``` | |
| celery -A utils.celery_tasks.celery_app worker --loglevel=info | |
| ``` | |
| 2. **Flower (Optional)**: You can install and run Flower for a web-based monitoring UI: | |
| ``` | |
| pip install flower | |
| celery -A utils.celery_tasks.celery_app flower | |
| ``` | |
| Access 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: | |
| 1. Check if your Redis server is running | |
| 2. Verify the host, port, and password are correct | |
| 3. Check if any firewall is blocking the Redis port | |
| 4. Ensure Redis is configured to accept remote connections (if connecting remotely) | |
| 5. Try connecting using the redis-cli tool: | |
| ``` | |
| redis-cli -h your-host -p your-port -a your-password ping | |
| ``` | |
| You should receive "PONG" as the response if the connection is successful | |
| ## Security Considerations | |
| 1. Use a strong password for Redis authentication | |
| 2. Don't expose your Redis server directly to the internet | |
| 3. Consider using SSL/TLS if connecting to Redis over untrusted networks | |
| 4. Avoid hardcoding Redis credentials in your application code |