Skip to content

Commit d3b56b4

Browse files
committed
move client update to bottom of loop
1 parent 9f942b7 commit d3b56b4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

app.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,6 @@ func runService(ctx context.Context, wg *sync.WaitGroup, cancel context.CancelFu
146146
}
147147
MainLoop:
148148
for {
149-
client, err := dataStore.GetClientForMachine()
150-
if err != nil {
151-
_ = glg.Warnf("could not refresh client %s, using cached data", client.Name)
152-
}
153-
154149
// check if client is allowed to run
155150
canRun := tools.InTimeSpan(client.AvailabilityStart, client.AvailabilityEnd, time.Now())
156151
if !canRun && !sleep {
@@ -200,6 +195,12 @@ MainLoop:
200195
case <-globalstate.WakeChan():
201196
case <-time.After(time.Duration(sleepTime) * time.Minute):
202197
}
198+
199+
// refresh client after sleeping time to ensure settings are updated properly
200+
client, err := dataStore.GetClientForMachine()
201+
if err != nil {
202+
_ = glg.Warnf("could not refresh client %s, using cached data", client.Name)
203+
}
203204
}
204205
_ = dataStore.SignOutThisClient()
205206
apiChan <- "stop"

0 commit comments

Comments
 (0)