all repos — cameraman @ 33229b4ef241f4fc2776ea94d2fb47dbf1e039e5

read new config from .env
Marco Andronaco andronacomarco@gmail.com
Mon, 12 Aug 2024 19:39:52 +0200
commit

33229b4ef241f4fc2776ea94d2fb47dbf1e039e5

parent

89eab556b38d04c80687610802d3397ddd83800d

2 files changed, 14 insertions(+), 6 deletions(-)

jump to
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.gomain.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 {