From 863bd6fb6e665f6ad9c31d22a89414b7c45475da Mon Sep 17 00:00:00 2001 From: GHOSCHT <31184695+GHOSCHT@users.noreply.github.com> Date: Tue, 31 Dec 2024 14:14:22 +0100 Subject: [PATCH] Prevent premature scheduler shutdown --- main.go | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/main.go b/main.go index b521b14..1b933e3 100644 --- a/main.go +++ b/main.go @@ -126,9 +126,9 @@ func main() { fmt.Println("Couldn't find a .env file, assuming already present environment variables") } - var username string = os.Getenv("PIPED_USERNAME") // piped username - var password string = os.Getenv("PIPED_PASSWORD") // piped password - var basePath string = os.Getenv("PIPED_API_URL") // piped API URL + var username string = os.Getenv("PIPED_USERNAME") // piped username + var password string = os.Getenv("PIPED_PASSWORD") // piped password + var basePath string = os.Getenv("PIPED_API_URL") // piped API URL var cronSchedule string = os.Getenv("QUERY_CRON") // cron schedule how often update should be triggered maxWaitTime, err := strconv.Atoi(os.Getenv("QUERY_WAIT_TIME")) // in milliseconds, change for potential ban evasion if err != nil { @@ -159,6 +159,7 @@ func main() { gocron.WithSingletonMode(gocron.LimitModeReschedule), ) if err != nil { + fmt.Println("Error creating task") panic(err) } @@ -167,14 +168,8 @@ func main() { fmt.Print("Starting scheduler...\n\n") - // block until you are ready to shut down - select { - case <-time.After(time.Minute): - } - - // when you're done, shut it down - err = s.Shutdown() - if err != nil { - panic(err) + // sleep for infinity and respond to scheduled tasks + for { + time.Sleep(infinityDuration) } }