CodePilot
Background Workers

Redis

Redis configuration for BullMQ job queues and caching in CodePilot.

CodePilot uses Redis as the backing store for BullMQ job queues. Redis Stack is used in development to also provide RedisInsight for monitoring.

Docker Setup

Redis is provided via Docker Compose:

docker-compose.yml
services:
  redis-stack:
    image: redis/redis-stack:latest
    container_name: codepilot_redis
    restart: unless-stopped
    ports:
      - "${REDIS_PORT:-6379}:6379"
      - "${REDIS_STACK_PORT:-8001}:8001"
    volumes:
      - redis_data:/data
PortService
6379Redis server
8001RedisInsight web UI

Connection Configuration

The Redis connection is configured via environment variables:

.env.api
REDIS_HOST=localhost
REDIS_PORT=6379

In application code:

const redisConnection = {
  host: process.env.REDIS_HOST || "localhost",
  port: parseInt(process.env.REDIS_PORT || "6379"),
};

Docker Networking

When running apps inside Docker containers, use the Docker service name (redis-stack) instead of localhost for REDIS_HOST. In development with apps running natively, use localhost.

Data Persistence

Redis data is persisted using a Docker volume:

volumes:
  redis_data:
    driver: local
    name: codepilot_redis_data

This ensures job queue data survives container restarts.

Health Check (Production)

In production, Redis includes a health check:

docker-compose.prod.yml
redis-stack:
  healthcheck:
    test: ["CMD", "redis-cli", "ping"]
    interval: 10s
    timeout: 5s
    retries: 5

Other services depend on Redis being healthy before starting:

api:
  depends_on:
    redis-stack:
      condition: service_healthy

Monitoring with RedisInsight

RedisInsight is available at http://localhost:8001 and provides:

  • Key browser for inspecting BullMQ queue data
  • Memory analysis
  • Slow log viewer
  • CLI interface

Production Considerations

  • Memory: Redis stores job data in memory. For large repositories, ensure adequate memory
  • Persistence: Redis Stack uses both RDB snapshots and AOF logging for durability
  • Connection pooling: BullMQ manages its own connection pool to Redis
  • Sentinel/Cluster: For high availability, Redis Sentinel or Cluster can be configured (not included in the default setup)

On this page