mirror of
https://github.com/terorie/od-database-crawler.git
synced 2025-04-18 01:46:43 +00:00
Fix too long sleep
This commit is contained in:
parent
e919323169
commit
ef7d17cad4
11
main.go
11
main.go
@ -97,7 +97,7 @@ func cmdBase(_ *cobra.Command, _ []string) {
|
||||
if err != nil {
|
||||
logrus.WithError(err).
|
||||
Error("Failed to get new task")
|
||||
time.Sleep(viper.GetDuration(ConfCooldown))
|
||||
sleep(viper.GetDuration(ConfCooldown), appCtx)
|
||||
continue
|
||||
}
|
||||
if t == nil {
|
||||
@ -189,3 +189,12 @@ func hardShutdown(c context.Context) {
|
||||
<-c.Done()
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func sleep(d time.Duration, c context.Context) {
|
||||
select {
|
||||
case <-time.After(d):
|
||||
break
|
||||
case <-c.Done():
|
||||
break
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user