main.go 硬编码 gin.ReleaseMode 改成读 cfg.GinMode(默认 release),
方便生产/调试切换 debug/release/test。Load() 开头先调 loadDotenv
(".env"): 缺文件静默跳过,shell env 优先于 .env,跳过注释/空行/
无 '=' 行并 slog.Warn。仅用标准库,不引新依赖。
验证:
- go build / go vet / go test 全部通过
- shell env 覆盖 .env (LISTEN_ADDR=:19090 覆盖 .env 的 :18080)
- 仅 .env 时正确加载 (监听 18080, GIN_MODE=debug 输出 [GIN-debug])
- 无 .env 且无 shell env 时清晰报错 ADMIN_TOKENS is not set
Co-Authored-By: Claude <noreply@anthropic.com>
41 lines
1.1 KiB
Bash
41 lines
1.1 KiB
Bash
# spark-mcp-go environment configuration
|
|
# Copy to .env and edit the *REQUIRED* values.
|
|
|
|
# HTTP listen address (default: :8080)
|
|
LISTEN_ADDR=:8080
|
|
|
|
# Root directory for SQLite, uploads, and logs (default: ./data)
|
|
DATA_DIR=./data
|
|
|
|
# *REQUIRED* Comma-separated admin bearer tokens for /admin/* endpoints
|
|
ADMIN_TOKENS=change-me-admin-token-1,change-me-admin-token-2
|
|
|
|
# *REQUIRED* Agent bearer token for /mcp endpoints
|
|
AGENT_TOKEN=change-me-agent-token
|
|
|
|
# Timeout for fetch_url and RM tool HTTP calls (default: 30s)
|
|
HTTP_CLIENT_TIMEOUT=30s
|
|
|
|
# Maximum HTTP response bytes before truncation (default: 1048576)
|
|
MAX_RESPONSE_BYTES=1048576
|
|
|
|
# Timeout for spark-submit process execution (default: 60s)
|
|
SPARK_SUBMIT_TIMEOUT=60s
|
|
|
|
# Log directory (default: ./data/logs)
|
|
LOG_DIR=./data/logs
|
|
|
|
# Log level: debug, info, warn, error (default: info)
|
|
LOG_LEVEL=info
|
|
|
|
# Log format: text (terminal) or json (log file; default: text)
|
|
LOG_FORMAT=text
|
|
|
|
# Gin mode: debug, release, test (default: release)
|
|
GIN_MODE=release
|
|
|
|
# Analyzer heuristic thresholds (defaults shown)
|
|
ANALYZER_DATA_SKEW_RATIO=3.0
|
|
ANALYZER_GC_PRESSURE_RATIO=0.1
|
|
ANALYZER_BOTTLENECK_SHUFFLE_GB=50
|