code: func (d *Daemon) Run() error {
  	email, hasEmail := os.LookupEnv("TORUS_EMAIL")
  	password, hasPassword := os.LookupEnv("TORUS_PASSWORD")
  	tokenID, hasTokenID := os.LookupEnv("TORUS_TOKEN_ID")
  	tokenSecret, hasTokenSecret := os.LookupEnv("TORUS_TOKEN_SECRET")
  
  	if hasEmail && hasPassword {
  		log.Printf("Attempting to login as: %s", email)
  		userLogin := &apitypes.UserLogin{
  			Email:    email,
  			Password: password,
  		}
  
  		err := d.logic.Session.Login(context.Background(), userLogin)
  		if err != nil {
  			return err
  		}
  	}
  
  	if hasTokenID && hasTokenSecret {
  		log.Printf("Attempting to login as machine token id: %s", tokenID)
  
  		ID, err := identity.DecodeFromString(tokenID)
  		if err != nil {
  			log.Printf("Could not parse TORUS_TOKEN_ID")
  			return err
  		}
  
  		secret, err := base64.NewFromString(tokenSecret)
  		if err != nil {
  			log.Printf("Could not parse TORUS_TOKEN_SECRET")
  			return err
  		}
  
  		machineLogin := &apitypes.MachineLogin{
  			TokenID: &ID,
  			Secret:  secret,
  		}
  
  		err = d.logic.Session.Login(context.Background(), machineLogin)
  		if err != nil {
  			return err
  		}
  	}
  
  	if err := d.updates.Start(); err != nil {
  		log.Printf("cannot start updates checker: %s", err)
  	}
  
  	return d.proxy.Listen()
  }
docs: // Run starts the daemon main loop. It returns on failure, or when the daemon
  // has been gracefully shut down.