runEntityChecker runs the periodic check againt Asterisk entity id
(ctx context.Context)
| 222 | |
| 223 | // runEntityChecker runs the periodic check againt Asterisk entity id |
| 224 | func (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 |
| 248 | func (s *Server) runAnnouncer(ctx context.Context) { |