diff --git a/cmd/cc-backend/main.go b/cmd/cc-backend/main.go index e1546c7..3a49923 100644 --- a/cmd/cc-backend/main.go +++ b/cmd/cc-backend/main.go @@ -83,8 +83,6 @@ func main() { config.Keys.DB = os.Getenv(envvar) } - repository.Connect(config.Keys.DBDriver, config.Keys.DB) - if flagMigrateDB { err := repository.MigrateDB(config.Keys.DBDriver, config.Keys.DB) if err != nil { @@ -109,6 +107,8 @@ func main() { os.Exit(0) } + repository.Connect(config.Keys.DBDriver, config.Keys.DB) + if flagInit { initEnv() fmt.Print("Succesfully setup environment!\n") @@ -227,6 +227,8 @@ func main() { <-sigs runtimeEnv.SystemdNotifiy(false, "Shutting down ...") + serverShutdown() + taskManager.Shutdown() }() diff --git a/internal/taskManager/taskManager.go b/internal/taskManager/taskManager.go index bcd2c06..006469c 100644 --- a/internal/taskManager/taskManager.go +++ b/internal/taskManager/taskManager.go @@ -75,7 +75,7 @@ func Start() { lc := config.Keys.LdapConfig - if lc.SyncInterval != "" { + if lc != nil && lc.SyncInterval != "" { RegisterLdapSyncService(lc.SyncInterval) }