read new config from .env
Marco Andronaco andronacomarco@gmail.com
Mon, 12 Aug 2024 19:39:52 +0200
2 files changed,
14 insertions(+),
6 deletions(-)
M
.env.example
→
.env.example
@@ -4,4 +4,5 @@ TELEGRAM_THREAD_ID=your_thread_id
PORT=3000 HOURS_BETWEEN_CHECKS=1 -DAYS_BEFORE_NOTIFICATION=3 +DAYS_BEFORE_NOTIFICATION=5 +DAYS_BEFORE_SOFT_NOTIFICATION=2
M
main.go
→
main.go
@@ -31,11 +31,12 @@ NotifiedSoft bool `json:"notified_soft"`
} const ( - dataDir = "data" - dbFile = "occurrences.db" - defaultNotificationWindow = 3 - defaultSleepDuration = 1 - defaultPort = "3000" + dataDir = "data" + dbFile = "occurrences.db" + defaultNotificationWindow = 5 + defaultSoftNotificationWindow = 2 + defaultSleepDuration = 1 + defaultPort = "3000" ) var (@@ -71,6 +72,12 @@ if err != nil {
NotificationWindow = defaultNotificationWindow } log.Println("Notification window (days):", NotificationWindow) + + SoftNotificationWindow, err = strconv.Atoi(os.Getenv("DAYS_BEFORE_SOFT_NOTIFICATION")) + if err != nil { + SoftNotificationWindow = defaultSoftNotificationWindow + } + log.Println("Soft notification window (days):", SoftNotificationWindow) loadedSleepDuration, err := strconv.Atoi(os.Getenv("HOURS_BETWEEN_CHECKS")) if err != nil {