mirror of
https://github.com/edgebox-iot/edgeboxctl.git
synced 2026-11-13 03:49:47 +01:00
Extracted isSystemReady to outer loop
This commit is contained in:
+7
-8
@@ -65,8 +65,15 @@ func main() {
|
|||||||
// infinite loop
|
// infinite loop
|
||||||
for {
|
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...
|
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)
|
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)
|
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)
|
tasks.ExecuteSchedules(tick)
|
||||||
nextTask := tasks.GetNextTask()
|
nextTask := tasks.GetNextTask()
|
||||||
if nextTask.Task != "" {
|
if nextTask.Task != "" {
|
||||||
@@ -125,6 +126,4 @@ func systemIterator(name *string, tick int) {
|
|||||||
log.Printf("Next instruction will be executed 1 second")
|
log.Printf("Next instruction will be executed 1 second")
|
||||||
time.Sleep(defaultSleepTime)
|
time.Sleep(defaultSleepTime)
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user