code: func (a *Agent) loadProxies(conf *config.RuntimeConfig) error {
  	persistedProxies, persistenceErr := a.loadPersistedProxies()
  
  	for _, svc := range conf.Services {
  		if svc.Connect != nil {
  			proxy, err := svc.ConnectManagedProxy()
  			if err != nil {
  				return fmt.Errorf("failed adding proxy: %s", err)
  			}
  			if proxy == nil {
  				continue
  			}
  			restoredToken := ""
  			if persisted, ok := persistedProxies[proxy.TargetServiceID]; ok {
  				restoredToken = persisted.ProxyToken
  			}
  
  			if err := a.addProxyLocked(proxy, true, true, restoredToken, ConfigSourceLocal); err != nil {
  				return fmt.Errorf("failed adding proxy: %s", err)
  			}
  		}
  	}
  
  	for _, persisted := range persistedProxies {
  		proxyID := persisted.Proxy.ProxyService.ID
  		if persisted.FromFile && a.State.Proxy(proxyID) == nil {
  			// Purge proxies that were configured previously but are no longer in the config
  			a.logger.Printf("[DEBUG] agent: purging stale persisted proxy %q", proxyID)
  			if err := a.purgeProxy(proxyID); err != nil {
  				return fmt.Errorf("failed purging proxy %q: %v", proxyID, err)
  			}
  		} else if !persisted.FromFile {
  			if a.State.Proxy(proxyID) == nil {
  				a.logger.Printf("[DEBUG] agent: restored proxy definition %q", proxyID)
  				if err := a.addProxyLocked(persisted.Proxy, false, false, persisted.ProxyToken, ConfigSourceLocal); err != nil {
  					return fmt.Errorf("failed adding proxy %q: %v", proxyID, err)
  				}
  			} else {
  				a.logger.Printf("[WARN] agent: proxy definition %q was overwritten by a proxy definition within a config file", proxyID)
  			}
  		}
  	}
  
  	return persistenceErr
  }
docs: // loadProxies will load connect proxy definitions from configuration and
  // persisted definitions on disk, and load them into the local agent.