Prevent premature scheduler shutdown
This commit is contained in:
parent
7041b8672f
commit
863bd6fb6e
1 changed files with 7 additions and 12 deletions
19
main.go
19
main.go
|
@ -126,9 +126,9 @@ func main() {
|
||||||
fmt.Println("Couldn't find a .env file, assuming already present environment variables")
|
fmt.Println("Couldn't find a .env file, assuming already present environment variables")
|
||||||
}
|
}
|
||||||
|
|
||||||
var username string = os.Getenv("PIPED_USERNAME") // piped username
|
var username string = os.Getenv("PIPED_USERNAME") // piped username
|
||||||
var password string = os.Getenv("PIPED_PASSWORD") // piped password
|
var password string = os.Getenv("PIPED_PASSWORD") // piped password
|
||||||
var basePath string = os.Getenv("PIPED_API_URL") // piped API URL
|
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
|
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
|
maxWaitTime, err := strconv.Atoi(os.Getenv("QUERY_WAIT_TIME")) // in milliseconds, change for potential ban evasion
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -159,6 +159,7 @@ func main() {
|
||||||
gocron.WithSingletonMode(gocron.LimitModeReschedule),
|
gocron.WithSingletonMode(gocron.LimitModeReschedule),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("Error creating task")
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,14 +168,8 @@ func main() {
|
||||||
|
|
||||||
fmt.Print("Starting scheduler...\n\n")
|
fmt.Print("Starting scheduler...\n\n")
|
||||||
|
|
||||||
// block until you are ready to shut down
|
// sleep for infinity and respond to scheduled tasks
|
||||||
select {
|
for {
|
||||||
case <-time.After(time.Minute):
|
time.Sleep(infinityDuration)
|
||||||
}
|
|
||||||
|
|
||||||
// when you're done, shut it down
|
|
||||||
err = s.Shutdown()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue