Skip to content

Commit c7aad63

Browse files
committed
configure ticker interval
1 parent 4bb7f92 commit c7aad63

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

main.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"log"
77
"os"
8+
"strconv"
89
"strings"
910
"sync"
1011
"time"
@@ -72,9 +73,19 @@ func main() {
7273
}
7374
}()
7475
}
76+
// Get ticker interval from environment variable, default to 5 minutes
77+
tickerIntervalMinutes := 5
78+
if intervalStr := os.Getenv("TICKER_INTERVAL_MINUTES"); intervalStr != "" {
79+
if interval, err := strconv.Atoi(intervalStr); err == nil && interval > 0 {
80+
tickerIntervalMinutes = interval
81+
} else {
82+
log.Printf("Invalid TICKER_INTERVAL_MINUTES value '%s', using default of 5 minutes", intervalStr)
83+
}
84+
}
85+
log.Printf("Ticker interval set to %d minutes", tickerIntervalMinutes)
7586

7687
go func() {
77-
ticker := time.NewTicker(5 * time.Minute)
88+
ticker := time.NewTicker(time.Duration(tickerIntervalMinutes) * time.Minute)
7889
defer ticker.Stop()
7990

8091
for {

0 commit comments

Comments
 (0)