go-pingbot/backend/ticker.go

28 lines
307 B
Go
Raw Normal View History

2021-07-11 21:19:37 +00:00
package backend
import (
"time"
"gitlab.com/gaming0skar123/go/pingbot/config"
2021-07-11 21:19:37 +00:00
)
func Ticker() {
// Ping on Start
2021-07-11 21:19:37 +00:00
ping()
ticker := time.NewTicker(config.PingBot_Ticker)
2021-07-11 21:19:37 +00:00
quit := make(chan struct{})
for {
select {
case <-ticker.C:
ping()
case <-quit:
ticker.Stop()
2021-07-11 21:19:37 +00:00
return
}
}
}