Start syncer dynamically.

This commit is contained in:
Gucheng Wang
2022-01-17 20:09:29 +08:00
parent d183b9eca9
commit d9bcce9485
3 changed files with 43 additions and 17 deletions

View File

@ -158,22 +158,7 @@ func (syncer *Syncer) initAdapter() {
func RunSyncUsersJob() {
syncers := GetSyncers("admin")
for _, syncer := range syncers {
if !syncer.IsEnabled {
continue
}
syncer.initAdapter()
syncer.syncUsers()
schedule := fmt.Sprintf("@every %ds", syncer.SyncInterval)
cron := getCronMap(syncer.Name)
_, err := cron.AddFunc(schedule, syncer.syncUsers)
if err != nil {
panic(err)
}
cron.Start()
addSyncerJob(syncer)
}
time.Sleep(time.Duration(1<<63 - 1))