Skip to main content

Configuration Reference

All Sercha Core configuration is done via environment variables.

Core Settings

VariableDefaultDescription
RUN_MODEallRun mode: all, api, or worker
PORT8080HTTP server port (API and combined modes)
JWT_SECRET-Secret for signing JWT tokens (required)
TEAM_IDdefault-teamTeam identifier for multi-tenant setups

Database

VariableDefaultDescription
DATABASE_URL-PostgreSQL connection string (required)
DB_MAX_OPEN_CONNS25Maximum open connections
DB_MAX_IDLE_CONNS5Maximum idle connections
DB_CONN_MAX_LIFETIME_SEC300Connection max lifetime in seconds
DB_CONN_MAX_IDLE_SEC60Connection max idle time in seconds

Connection String Format

postgres://user:password@host:port/database?sslmode=disable

Redis (Optional)

VariableDefaultDescription
REDIS_URL-Redis connection string (optional)

When REDIS_URL is set, Sercha uses Redis for:

  • Session storage (faster than PostgreSQL)
  • Task queue (supports distributed workers)
  • Distributed locks (scheduler coordination)

When not set, PostgreSQL is used for all of the above.

Connection String Format

redis://host:port
redis://:password@host:port

Vespa

VariableDefaultDescription
VESPA_URLhttp://localhost:19071Vespa config endpoint

Worker Settings

These apply to worker and all modes:

VariableDefaultDescription
WORKER_CONCURRENCY2Number of concurrent task processors
WORKER_DEQUEUE_TIMEOUT5Seconds to wait when queue is empty

Scheduler Settings

VariableDefaultDescription
SCHEDULER_ENABLEDtrueEnable the task scheduler
SCHEDULER_LOCK_REQUIREDtrueRequire distributed lock for scheduling

When running multiple worker containers, SCHEDULER_LOCK_REQUIRED=true ensures only one worker schedules tasks per cycle, preventing duplicates.

Example Configurations

Development (Combined Mode)

environment:
DATABASE_URL: postgres://sercha:dev@postgres:5432/sercha?sslmode=disable
JWT_SECRET: dev-secret-change-in-production
VESPA_URL: http://vespa:19071

Production API

environment:
RUN_MODE: api
PORT: 8080
DATABASE_URL: postgres://sercha:${DB_PASSWORD}@db.example.com:5432/sercha
REDIS_URL: redis://redis.example.com:6379
VESPA_URL: http://vespa.example.com:19071
JWT_SECRET: ${JWT_SECRET}
DB_MAX_OPEN_CONNS: 50
DB_MAX_IDLE_CONNS: 10

Production Worker

environment:
RUN_MODE: worker
DATABASE_URL: postgres://sercha:${DB_PASSWORD}@db.example.com:5432/sercha
REDIS_URL: redis://redis.example.com:6379
VESPA_URL: http://vespa.example.com:19071
JWT_SECRET: ${JWT_SECRET}
WORKER_CONCURRENCY: 4
SCHEDULER_ENABLED: "true"
SCHEDULER_LOCK_REQUIRED: "true"

Next Steps