code: func (a *Agent) persistService(service *structs.NodeService) error {
  	svcPath := filepath.Join(a.config.DataDir, servicesDir, stringHash(service.ID))
  
  	wrapped := persistedService{
  		Token:   a.State.ServiceToken(service.ID),
  		Service: service,
  	}
  	encoded, err := json.Marshal(wrapped)
  	if err != nil {
  		return err
  	}
  
  	return file.WriteAtomic(svcPath, encoded)
  }
docs: // persistService saves a service definition to a JSON file in the data dir