MCPcopy Create free account
hub / github.com/CyCoreSystems/ari-proxy / runEntityChecker

Method runEntityChecker

server/server.go:224–245  ·  view source on GitHub ↗

runEntityChecker runs the periodic check againt Asterisk entity id

(ctx context.Context)

Source from the content-addressed store, hash-verified

222
223// runEntityChecker runs the periodic check againt Asterisk entity id
224func (s *Server) runEntityChecker(ctx context.Context) {
225 ticker := time.NewTicker(proxy.EntityCheckInterval)
226 defer ticker.Stop()
227
228 for {
229 select {
230 case <-ctx.Done():
231 return
232 case <-ticker.C:
233 info, err := s.ari.Asterisk().Info(nil)
234 if err != nil {
235 s.Log.Error("failed to get info from Asterisk", "error", err)
236 continue
237 }
238 if s.AsteriskID != info.SystemInfo.EntityID {
239 s.Log.Warn("system entitiy id changed", "old", s.AsteriskID, "new", info.SystemInfo.EntityID)
240 // We need to exit with non-zero to make sure systemd restarts when service defined with Restart=on-failure
241 os.Exit(1)
242 }
243 }
244 }
245}
246
247// runAnnouncer runs the periodic discovery announcer
248func (s *Server) runAnnouncer(ctx context.Context) {

Callers 1

listenMethod · 0.95

Calls 5

DoneMethod · 0.80
InfoMethod · 0.80
AsteriskMethod · 0.80
StopMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected