Skip to content

Commit db8a2e1

Browse files
committed
increases timeout of no tasks are installed
1 parent b515296 commit db8a2e1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

core/tasks.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,21 +132,24 @@ func RotateTasks(event string, silent bool) error {
132132
fmt.Println("---")
133133
}
134134
cChecks := GetCommonChecks()
135-
err := runTasksRotator(cChecks, event, silent)
135+
rotatedCount, err := runTasksRotator(cChecks, event, silent)
136136
if err != nil {
137137
fmt.Println(err)
138+
} else if rotatedCount == 0 {
139+
// avoid running constantly if no tasks are installed
140+
time.Sleep(60 * time.Second)
138141
}
139142

140143
time.Sleep(5 * time.Second)
141144
}
142145
}
143146

144147
// runTasksRotator checks which tasks should be run and starts rotating
145-
func runTasksRotator(cChecks *CommonChecks, event string, silent bool) error {
148+
func runTasksRotator(cChecks *CommonChecks, event string, silent bool) (int, error) {
146149
var err error
147150
CurrentQueue, err = ListTasksDetailed()
148151
if err != nil {
149-
return err
152+
return 0, err
150153
}
151154

152155
rotatedN := 0
@@ -158,7 +161,7 @@ func runTasksRotator(cChecks *CommonChecks, event string, silent bool) error {
158161
err = t.Run()
159162
if err != nil {
160163
rotatedNFails++
161-
return err
164+
return 0, err
162165
}
163166
}
164167

@@ -172,7 +175,7 @@ func runTasksRotator(cChecks *CommonChecks, event string, silent bool) error {
172175
fmt.Printf("Rotated %d tasks, %d failed, %d success\n", rotatedN, rotatedNFails, rotatedNSuccess)
173176
}
174177

175-
return nil
178+
return rotatedN, nil
176179
}
177180

178181
// saveTasksRotatorRunning saves that the rotator is running

0 commit comments

Comments
 (0)