diff options
-rw-r--r-- | mattermost.go | 4 | ||||
-rw-r--r-- | model/job.go | 7 | ||||
-rw-r--r-- | model/ldap.go | 1 | ||||
-rw-r--r-- | utils/config.go | 6 |
4 files changed, 12 insertions, 6 deletions
diff --git a/mattermost.go b/mattermost.go index bdfa55d9a..4cca4c200 100644 --- a/mattermost.go +++ b/mattermost.go @@ -133,10 +133,6 @@ func main() { complianceI.StartComplianceDailyJob() } - if ldapI := einterfaces.GetLdapInterface(); ldapI != nil { - ldapI.StartLdapSyncJob() - } - // wait for kill signal before attempting to gracefully shutdown // the running service c := make(chan os.Signal) diff --git a/model/job.go b/model/job.go index bcae7a830..b6c68dce4 100644 --- a/model/job.go +++ b/model/job.go @@ -28,8 +28,11 @@ func removeTaskByName(name string) { delete(tasks, name) } -func getTaskByName(name string) *ScheduledTask { - return tasks[name] +func GetTaskByName(name string) *ScheduledTask { + if task, ok := tasks[name]; ok { + return task + } + return nil } func GetAllTasks() *map[string]*ScheduledTask { diff --git a/model/ldap.go b/model/ldap.go index 5fde06a6e..71b1d8a6b 100644 --- a/model/ldap.go +++ b/model/ldap.go @@ -5,4 +5,5 @@ package model const ( USER_AUTH_SERVICE_LDAP = "ldap" + LDAP_SYNC_TASK_NAME = "LDAP Syncronization" ) diff --git a/utils/config.go b/utils/config.go index 79d1d8e4b..60d09dee3 100644 --- a/utils/config.go +++ b/utils/config.go @@ -186,6 +186,12 @@ func LoadConfig(fileName string) { Cfg = &config ClientCfg = getClientConfig(Cfg) + + // Actions that need to run every time the config is loaded + if ldapI := einterfaces.GetLdapInterface(); ldapI != nil { + // This restarts the job if nessisary (works for config reloads) + ldapI.StartLdapSyncJob() + } } func getClientConfig(c *model.Config) map[string]string { |