Skip to content

Environment Variables

This page documents all environment variables used to configure Alita Robot.

Hours between activity checks

PropertyValue
Typeinteger
RequiredNo
Default1
Validationmin=1,max=24

Whether to automatically mark inactive chats

PropertyValue
Typeboolean
RequiredNo
Defaulttrue

Days before marking a chat as inactive

PropertyValue
Typeinteger
RequiredNo
Default30
Validationmin=1,max=365
PropertyValue
Typeinteger
RequiredYes
Validationrequired,min=1
PropertyValue
Typeinteger
RequiredYes
Validationrequired,min=1
PropertyValue
Typeboolean
RequiredNo
Defaultfalse

Comma-separated list of enabled language codes (e.g., en,es,fr,hi). Only these locales will be loaded.

PropertyValue
Typestring[]
RequiredNo
Defaulten
PropertyValue
Typestring
RequiredYes
Validationrequired

Custom Telegram Bot API server URL. Used with local telegram-bot-api server.

PropertyValue
Typestring
RequiredNo
Defaulthttps://api.telegram.org

Telegram API ID for local telegram-bot-api server. Obtain from https://my.telegram.org/apps.

PropertyValue
Typeinteger
RequiredNo

Telegram API hash for local telegram-bot-api server. Obtain from https://my.telegram.org/apps.

PropertyValue
Typestring
RequiredNo

Enables debug logging and disables automatic performance monitoring.

PropertyValue
Typeboolean
RequiredNo
Defaultfalse
PropertyValue
Typestring
RequiredNo
Defaultworker
PropertyValue
Typestring
RequiredYes
Validationrequired

📂 Database connection pool configuration

Section titled “📂 Database connection pool configuration”

Max idle time in minutes

PropertyValue
Typeinteger
RequiredNo
Default60
Validationmin=1,max=60

Max lifetime in minutes

PropertyValue
Typeinteger
RequiredNo
Default240
Validationmin=1,max=1440
PropertyValue
Typeinteger
RequiredNo
Default50
Validationmin=1,max=100
PropertyValue
Typeinteger
RequiredNo
Default200
Validationmin=1,max=1000

Enable automatic database migrations on startup

PropertyValue
Typeboolean
RequiredNo
Defaultfalse

Continue running even if migrations fail

PropertyValue
Typeboolean
RequiredNo
Defaultfalse

Path to migration files

PropertyValue
Typestring
RequiredNo
Defaultmigrations
PropertyValue
Typeboolean
RequiredNo
Defaultfalse

Batch request timeout in milliseconds

PropertyValue
Typeinteger
RequiredNo
Default100
Validationmin=10,max=5000

Enable async processing for non-critical operations

PropertyValue
Typeboolean
RequiredNo
Defaulttrue

Enable batch API requests

PropertyValue
Typeboolean
RequiredNo
Defaulttrue

Enable cache prewarming on startup

PropertyValue
Typeboolean
RequiredNo
Defaulttrue

Enable HTTP connection pooling

PropertyValue
Typeboolean
RequiredNo
Defaulttrue

Enable query batching and prefetching

PropertyValue
Typeboolean
RequiredNo
Defaulttrue

Enable response caching

PropertyValue
Typeboolean
RequiredNo
Defaulttrue

HTTP connection pool size

PropertyValue
Typeinteger
RequiredNo
Default100
Validationmin=10,max=1000

HTTP connections per host

PropertyValue
Typeinteger
RequiredNo
Default50
Validationmin=5,max=500

Response cache TTL in seconds

PropertyValue
Typeinteger
RequiredNo
Default30
Validationmin=1,max=3600

Enable pprof endpoints for performance profiling (development only)

PropertyValue
Typeboolean
RequiredNo
Defaultfalse

Unified HTTP server for health checks, metrics, and webhooks.

PropertyValue
Typeinteger
RequiredNo
Default8080
Validationmin=1,max=65535

Redis host:port. Alias for REDIS_URL host component. Either REDIS_ADDRESS or REDIS_URL is required.

PropertyValue
Typestring
RequiredYes*
Defaultlocalhost:6379

*Required if REDIS_URL is not set.

Standard Redis URL (redis://user:password@host:port). If set, REDIS_ADDRESS and REDIS_PASSWORD are extracted from it automatically. Takes lower priority than REDIS_ADDRESS/REDIS_PASSWORD if both are set.

PropertyValue
Typestring
RequiredYes*

*Required if REDIS_ADDRESS is not set.

PropertyValue
Typeinteger
RequiredNo
Default1
PropertyValue
Typestring
RequiredNo

Memory threshold for triggering GC

PropertyValue
Typeinteger
RequiredNo
Default400
Validationmin=100,max=5000

Maximum goroutines before triggering cleanup

PropertyValue
Typeinteger
RequiredNo
Default1000
Validationmin=100,max=10000

Maximum memory usage in MB

PropertyValue
Typeinteger
RequiredNo
Default500
Validationmin=100,max=10000

Whether to clear all caches on bot startup

PropertyValue
Typeboolean
RequiredNo
Defaulttrue

Max concurrent goroutines for dispatcher

PropertyValue
Typeinteger
RequiredNo
Default200
Validationmin=1,max=1000

Automatically enabled in production (when DEBUG=false). Set to false to disable.

PropertyValue
Typeboolean
RequiredNo
Defaulttrue (production), false (debug)

Automatically enabled in production (when DEBUG=false). Set to false to disable.

PropertyValue
Typeboolean
RequiredNo
Defaulttrue (production), false (debug)
PropertyValue
Typeinteger
RequiredNo
Default50
Validationmin=1,max=1000

Timeout for operations in seconds. Converted to time.Duration internally at OperationTimeoutSeconds * time.Second.

PropertyValue
Typeinteger
RequiredNo
Default30
Validationmin=1,max=300
PropertyValue
Typeboolean
RequiredNo
Defaultfalse

Required when USE_WEBHOOKS=true.

PropertyValue
Typestring
RequiredConditional

Deprecated: use HTTP_PORT instead.

PropertyValue
Typeinteger
RequiredNo
Default8081
Validationmin=1,max=65535

Required when USE_WEBHOOKS=true.

PropertyValue
Typestring
RequiredConditional

Token for Cloudflare Tunnel (cloudflared) when using tunnel mode for webhooks.

PropertyValue
Typestring
RequiredNo

📂 Worker pool configuration for concurrent processing

Section titled “📂 Worker pool configuration for concurrent processing”
PropertyValue
Typeinteger
RequiredNo
Default4
Validationmin=1,max=20
PropertyValue
Typeinteger
RequiredNo
Default3
Validationmin=1,max=20
PropertyValue
Typeinteger
RequiredNo
Default10
Validationmin=1,max=100
PropertyValue
Typeinteger
RequiredNo
Default5
Validationmin=1,max=50

Default is number of CPU cores, capped at 8.

PropertyValue
Typeinteger
RequiredNo
Defaultruntime.NumCPU() (max 8)
Validationmin=1,max=50
PropertyValue
Typeinteger
RequiredNo
Default2
Validationmin=1,max=10
Terminal window
BOT_TOKEN=
DATABASE_URL=
MESSAGE_DUMP=
OWNER_ID=
REDIS_ADDRESS= # or REDIS_URL
Terminal window
ACTIVITY_CHECK_INTERVAL=# hours between activity checks (default: 1)
API_SERVER=# custom API server URL (default: https://api.telegram.org)
AUTO_MIGRATE=# enable automatic database migrations (default: false)
AUTO_MIGRATE_SILENT_FAIL=# continue even if migrations fail (default: false)
BATCH_REQUEST_TIMEOUT_MS=# batch timeout in ms (default: 100)
BULK_OPERATION_WORKERS=# (default: 4)
CACHE_WORKERS=# (default: 3)
CHAT_VALIDATION_WORKERS=# (default: 10)
CLEAR_CACHE_ON_STARTUP=# clear all caches on startup (default: true)
CLOUDFLARE_TUNNEL_TOKEN=# Cloudflare tunnel token for webhooks
DATABASE_WORKERS=# (default: 5)
DB_CONN_MAX_IDLE_TIME_MIN=# max idle time in min (default: 60)
DB_CONN_MAX_LIFETIME_MIN=# max lifetime in min (default: 240)
DB_MAX_IDLE_CONNS=# (default: 50)
DB_MAX_OPEN_CONNS=# (default: 200)
DEBUG=# enable debug logging (default: false)
DISPATCHER_MAX_ROUTINES=# (default: 200)
DROP_PENDING_UPDATES=# (default: false)
ENABLE_ASYNC_PROCESSING=# (default: true)
ENABLE_AUTO_CLEANUP=# (default: true)
ENABLE_BACKGROUND_STATS=# (default: true in prod, false in debug)
ENABLE_BATCH_REQUESTS=# (default: true)
ENABLE_CACHE_PREWARMING=# (default: true)
ENABLE_DB_MONITORING=# (default: false)
ENABLE_HTTP_CONNECTION_POOLING=# (default: true)
ENABLE_PERFORMANCE_MONITORING=# (default: true in prod, false in debug)
ENABLE_PPROF=# enable pprof endpoints (default: false)
ENABLE_QUERY_PREFETCHING=# (default: true)
ENABLE_RESPONSE_CACHING=# (default: true)
ENABLED_LOCALES=# comma-separated language codes (default: en)
HTTP_MAX_IDLE_CONNS=# (default: 100)
HTTP_MAX_IDLE_CONNS_PER_HOST=# (default: 50)
HTTP_PORT=# unified HTTP server port (default: 8080)
INACTIVITY_THRESHOLD_DAYS=# days before marking inactive (default: 30)
MAX_CONCURRENT_OPERATIONS=# (default: 50)
MESSAGE_PIPELINE_WORKERS=# (default: NumCPU, max 8)
MIGRATIONS_PATH=# path to migration files (default: migrations)
OPERATION_TIMEOUT_SECONDS=# timeout in seconds → time.Duration (default: 30)
REDIS_DB=# Redis database number (default: 1)
REDIS_PASSWORD=# Redis password
REDIS_URL=# Redis URL (fallback for REDIS_ADDRESS + REDIS_PASSWORD)
RESOURCE_GC_THRESHOLD_MB=# GC threshold in MB (default: 400)
RESOURCE_MAX_GOROUTINES=# max goroutines (default: 1000)
RESOURCE_MAX_MEMORY_MB=# max memory in MB (default: 500)
RESPONSE_CACHE_TTL=# response cache TTL in seconds (default: 30)
STATS_COLLECTION_WORKERS=# (default: 2)
TELEGRAM_API_HASH=# for local telegram-bot-api server
TELEGRAM_API_ID=# for local telegram-bot-api server
USE_WEBHOOKS=# enable webhook mode (default: false)
WEBHOOK_DOMAIN=# required if USE_WEBHOOKS=true
WEBHOOK_PORT=# deprecated, use HTTP_PORT (default: 8081)
WEBHOOK_SECRET=# required if USE_WEBHOOKS=true
WORKING_MODE=# (default: worker)