code: func (srv *Instance) WriteServerStatus(ctx context.Context, wg *sync.WaitGroup) {
  	defer wg.Done()
  
  	target := srv.cfg.Choria.StatusFilePath
  	freq := srv.cfg.Choria.StatusUpdateSeconds
  
  	writer := func() error {
  		if target == "" || freq == 0 {
  			srv.log.Debug("Server status writing has been disabled")
  			return nil
  		}
  
  		srv.log.Debugf("Writing server status to %s", target)
  
  		j, err := json.Marshal(srv.Status())
  		if err != nil {
  			return err
  		}
  
  		err = ioutil.WriteFile(target, j, 0644)
  		if err != nil {
  			return err
  		}
  
  		return os.Chmod(target, 0644)
  	}
  
  	err := writer()
  	if err != nil {
  		srv.log.Errorf("Initial server status write to %s failed: %s", target, err)
  	}
  
  	timer := time.NewTicker(time.Duration(freq) * time.Second)
  
  	for {
  		select {
  		case <-timer.C:
  			err = writer()
  			if err != nil {
  				srv.log.Errorf("Server status write to %s failed: %s", target, err)
  			}
  
  		case <-ctx.Done():
  			return
  		}
  	}
  }
docs: // WriteServerStatus periodically writes the server status to a file