code: func (a *Agent) ListenAndServe(ctx context.Context) error {
  	out.Debug(ctx, "Trying to listen on %s", a.socket)
  	lis, err := net.Listen("unix", a.socket)
  	if err == nil {
  		return a.server.Serve(lis)
  	}
  
  	out.Debug(ctx, "Failed to listen on %s: %s", a.socket, err)
  	if err := client.New(filepath.Dir(a.socket)).Ping(ctx); err == nil {
  		return fmt.Errorf("agent already running")
  	}
  	if err := os.Remove(a.socket); err != nil {
  		return errors.Wrapf(err, "failed to remove old agent socket %s: %s", a.socket, err)
  	}
  	out.Debug(ctx, "Trying to listen on %s after removing old socket", a.socket)
  	lis, err = net.Listen("unix", a.socket)
  	if err != nil {
  		return errors.Wrapf(err, "failed to listen on %s after cleanup: %s", a.socket, err)
  	}
  	return a.server.Serve(lis)
  }
docs: // ListenAndServe starts listening and blocks