Documentation

Configuration

Environment variables that control the HTTP server, sandbox limits, and Redis.

Loading

cmd/api calls godotenv.Load() at init. If .env is missing, the process logs a warning and continues with process environment variables only.

Copy .env.example and adjust values:

cp .env.example .env

Helpers in internal/utils (GetWithDefault, GetWithDefaultInt, GetWithDefaultFloat) supply defaults when a variable is unset or empty.

Variable Reference

Variable Required Default Used by Description
HTTP_PORT No 8080 internal.CreateServer HTTP listen port
MAX_CPUS No 1 sandbox.NewSlice CPU cores for slice CPUQuota (percent = cores × 100)
MAX_MEMORY No 128M sandbox.NewSlice Slice MemoryMax string
CODE_MAX_SIZE No 262144 handler.getCodeMaxSize Max run/upload body bytes (256KB)
TIMEOUT_SCRIPT No 30 handler.runScript* Script timeout seconds; request timeout adds Redis buffer
REDIS_HOST No localhost database.Init Redis host
REDIS_PORT No 6379 database.Init Redis port
REDIS_PASSWORD No empty database.Init Redis password
REDIS_DB No 0 database.Init Redis DB index
REDIS_TIMEOUT_SECONDS No 5 database.Init Dial/read/write/pool timeouts

Notes

中文