示例#1
0
文件: store.go 项目: whawty/auth
func (s *Store) reload() {
	wdl.Printf("store: reloading store config from '%s'", s.configfile)
	newdir, err := store.NewDirFromConfig(s.configfile)
	if err != nil {
		wl.Printf("store: reload failed: %v, keeping current configuration", err)
		return
	}
	if ok, err := newdir.Check(); err != nil || !ok {
		if err == nil {
			err = errors.New("this is not a valid store")
		}
		wl.Printf("store: reload failed: %v, keeping current configuration", err)
		return
	}

	s.dir = newdir
	s.hooks.NewStore <- s.dir.BaseDir
	wl.Printf("store: successfully reloaded")
}
示例#2
0
文件: store.go 项目: whawty/auth
func NewStore(configfile, doUpgrades, policyType, policyCondition, hooksDir string) (s *Store, err error) {
	s = &Store{}
	if s.dir, err = store.NewDirFromConfig(configfile); err != nil {
		return
	}
	s.configfile = configfile
	if s.policy, err = NewPasswordPolicy(policyType, policyCondition); err != nil {
		return
	}
	if s.hooks, err = NewHooksCaller(hooksDir, s.dir.BaseDir); err != nil {
		return
	}

	s.initChan = make(chan initRequest, 1)
	s.checkChan = make(chan checkRequest, 1)
	s.addChan = make(chan addRequest, 10)
	s.removeChan = make(chan removeRequest, 10)
	s.updateChan = make(chan updateRequest, 10)
	s.setAdminChan = make(chan setAdminRequest, 10)
	s.listChan = make(chan listRequest, 10)
	s.listFullChan = make(chan listFullRequest, 10)
	s.authenticateChan = make(chan authenticateRequest, 10)

	switch doUpgrades {
	case "":
		s.upgradeChan = nil
	case "local":
		s.upgradeChan = s.updateChan
	default:
		if s.upgradeChan, err = runRemoteUpgrader(doUpgrades); err != nil {
			return
		}
	}

	go s.dispatchRequests()
	return
}