Operations

Monitoring & Health

Cleanmails provides health endpoints and Docker-native monitoring for your instance.

Basic Health Check

bash
curl http://YOUR_SERVER/health

Returns 200 OK with {"status":"ok"} if the API server and PostgreSQL database are healthy. Returns 500 if the database connection is lost or ping fails.

Docker Health Checks

All containers have built-in health checks that Docker monitors continuously:

ServiceHealth CheckInterval
PostgreSQLpg_isready -U cleanmails5s
Redisredis-cli ping5s
APIcurl -f http://localhost:8080/health10s
Frontendwget --spider http://localhost:300010s

Checking Service Status

bash
cd /opt/cleanmails
docker compose -f docker-compose.prod.yml ps

This shows all containers with their current state and health status.

Queue Monitoring

The admin dashboard includes a Queue Health Monitor at /dashboard/admin/queues showing pending, active, completed, and failed jobs per queue. The background worker uses three priority queues:

QueuePriorityTasks
critical6Bounce/complaint handling
default3Campaign dispatch, lead validation
low1IMAP sync, AI replies, warmup

Application Logs

bash
cd /opt/cleanmails

# All services
docker compose -f docker-compose.prod.yml logs -f

# API only
docker compose -f docker-compose.prod.yml logs -f api

# Worker only
docker compose -f docker-compose.prod.yml logs -f worker

# Last 100 lines
docker compose -f docker-compose.prod.yml logs --tail=100 api

Worker Tasks

The worker processes these background tasks (logged at startup):

TaskDescription
imap:syncSync inbound emails from IMAP mailboxes
imap:schedule_syncSchedule periodic IMAP syncs for all mailboxes
ai:replyGenerate and send AI auto-replies
ai:reset_daily_tokensReset daily AI token budgets
campaign:dispatchSend scheduled campaign emails
system:reset_daily_capsReset daily send limits per mailbox
webhook:dispatchDeliver webhook payloads to subscribers
leads:validateValidate lead email addresses
system:license_checkPeriodic license validation
warmup:cycleSend warmup emails on schedule
warmup:replyAuto-reply to warmup emails

Resource Usage

bash
# Check memory usage per container
docker stats --no-stream

# Check disk usage
docker system df

Production memory limits are set per container (total ~1.5GB for the full stack). See the Docker Compose page for details.

Common Alerts to Watch

  • API unhealthy — Check PostgreSQL connectivity and disk space
  • Worker not processing — Check Redis connectivity and worker logs
  • High bounce rate — Campaign auto-pauses at 5% bounce rate
  • IMAP sync failures — Mailbox credentials may have expired
  • License check failures — Network connectivity to license server