load counter path from env

env
This commit is contained in:
Travis Shears 2025-10-11 22:19:13 +02:00
parent fb876226dd
commit be89141c06
Signed by: travisshears
GPG key ID: CB9BF1910F3F7469
2 changed files with 15 additions and 2 deletions

View file

@ -141,7 +141,13 @@ func main() {
flag.Parse()
// Initialize request counter with 30-second snapshot interval
counter, err := NewRequestCounter("request_counts.json", 30*time.Second)
requestCountsPath := os.Getenv("REQUEST_COUNTS_PATH")
if requestCountsPath == "" {
err = errors.New("REQUEST_COUNTS_PATH environment variable must be set and non-empty")
slog.Error("failed to initialize request counter", "error", err)
os.Exit(1)
}
counter, err := NewRequestCounter(30 * time.Second)
if err != nil {
slog.Error("failed to initialize request counter", "error", err)
os.Exit(1)