You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

setting.go 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2021 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package install
  5. import (
  6. "context"
  7. "code.gitea.io/gitea/modules/log"
  8. "code.gitea.io/gitea/modules/setting"
  9. "code.gitea.io/gitea/modules/svg"
  10. "code.gitea.io/gitea/modules/translation"
  11. "code.gitea.io/gitea/routers/common"
  12. )
  13. // PreloadSettings preloads the configuration to check if we need to run install
  14. func PreloadSettings(ctx context.Context) bool {
  15. setting.NewContext()
  16. if !setting.InstallLock {
  17. log.Trace("AppPath: %s", setting.AppPath)
  18. log.Trace("AppWorkPath: %s", setting.AppWorkPath)
  19. log.Trace("Custom path: %s", setting.CustomPath)
  20. log.Trace("Log path: %s", setting.LogRootPath)
  21. log.Trace("Preparing to run install page")
  22. translation.InitLocales()
  23. if setting.EnableSQLite3 {
  24. log.Info("SQLite3 Supported")
  25. }
  26. setting.InitDBConfig()
  27. svg.Init()
  28. }
  29. return !setting.InstallLock
  30. }
  31. // ReloadSettings rereads the settings and starts up the database
  32. func ReloadSettings(ctx context.Context) {
  33. setting.NewContext()
  34. setting.InitDBConfig()
  35. if setting.InstallLock {
  36. if err := common.InitDBEngine(ctx); err == nil {
  37. log.Info("ORM engine initialization successful!")
  38. } else {
  39. log.Fatal("ORM engine initialization failed: %v", err)
  40. }
  41. svg.Init()
  42. }
  43. }