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.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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.LoadAllowEmpty()
  16. if !setting.InstallLock {
  17. log.Info("AppPath: %s", setting.AppPath)
  18. log.Info("AppWorkPath: %s", setting.AppWorkPath)
  19. log.Info("Custom path: %s", setting.CustomPath)
  20. log.Info("Log path: %s", setting.LogRootPath)
  21. log.Info("Configuration file: %s", setting.CustomConf)
  22. log.Info("Prepare to run install page")
  23. translation.InitLocales()
  24. if setting.EnableSQLite3 {
  25. log.Info("SQLite3 is supported")
  26. }
  27. setting.InitDBConfig()
  28. setting.NewServicesForInstall()
  29. svg.Init()
  30. }
  31. return !setting.InstallLock
  32. }
  33. // reloadSettings reloads the existing settings and starts up the database
  34. func reloadSettings(ctx context.Context) {
  35. setting.LoadFromExisting()
  36. setting.InitDBConfig()
  37. if setting.InstallLock {
  38. if err := common.InitDBEngine(ctx); err == nil {
  39. log.Info("ORM engine initialization successful!")
  40. } else {
  41. log.Fatal("ORM engine initialization failed: %v", err)
  42. }
  43. svg.Init()
  44. }
  45. }