Extracted isSystemReady to outer loop

loop_loop_execution
Paulo Truta 2021-02-18 23:08:28 +00:00
parent 57a9ef3eed
commit 595c87c19c
1 changed files with 20 additions and 21 deletions

View File

@ -65,8 +65,15 @@ func main() {
// infinite loop
for {
if isSystemReady() {
tick++ // Tick is an int, so eventually will "go out of ticks?" Maybe we want to reset the ticks every once in a while, to avoid working with big numbers...
systemIterator(name, tick)
} else {
// Wait about 60 seconds before trying again.
log.Printf("System not ready. Next try will be executed in 60 seconds")
time.Sleep(defaultNotReadySleepTime)
}
}
@ -106,12 +113,6 @@ func systemIterator(name *string, tick int) {
log.Printf("Tick is %d", tick)
if isSystemReady() {
// Wait about 60 seconds before trying again.
log.Printf("System not ready. Next try will be executed in 60 seconds")
time.Sleep(defaultNotReadySleepTime)
} else {
tasks.ExecuteSchedules(tick)
nextTask := tasks.GetNextTask()
if nextTask.Task != "" {
@ -126,5 +127,3 @@ func systemIterator(name *string, tick int) {
time.Sleep(defaultSleepTime)
}
}