Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

init.go 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Copyright 2016 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 routers
  5. import (
  6. "path"
  7. "strings"
  8. "code.gitea.io/git"
  9. "code.gitea.io/gitea/models"
  10. "code.gitea.io/gitea/modules/cron"
  11. "code.gitea.io/gitea/modules/highlight"
  12. "code.gitea.io/gitea/modules/log"
  13. "code.gitea.io/gitea/modules/mailer"
  14. "code.gitea.io/gitea/modules/markdown"
  15. "code.gitea.io/gitea/modules/setting"
  16. "code.gitea.io/gitea/modules/ssh"
  17. macaron "gopkg.in/macaron.v1"
  18. )
  19. func checkRunMode() {
  20. switch setting.Cfg.Section("").Key("RUN_MODE").String() {
  21. case "prod":
  22. macaron.Env = macaron.PROD
  23. macaron.ColorLog = false
  24. setting.ProdMode = true
  25. default:
  26. git.Debug = true
  27. }
  28. log.Info("Run Mode: %s", strings.Title(macaron.Env))
  29. }
  30. // NewServices init new services
  31. func NewServices() {
  32. setting.NewServices()
  33. mailer.NewContext()
  34. }
  35. // GlobalInit is for global configuration reload-able.
  36. func GlobalInit() {
  37. setting.NewContext()
  38. log.Trace("Custom path: %s", setting.CustomPath)
  39. log.Trace("Log path: %s", setting.LogRootPath)
  40. models.LoadConfigs()
  41. NewServices()
  42. if setting.InstallLock {
  43. highlight.NewContext()
  44. markdown.BuildSanitizer()
  45. if err := models.NewEngine(); err != nil {
  46. log.Fatal(4, "Fail to initialize ORM engine: %v", err)
  47. }
  48. models.HasEngine = true
  49. models.LoadRepoConfig()
  50. models.NewRepoContext()
  51. // Booting long running goroutines.
  52. cron.NewContext()
  53. models.InitSyncMirrors()
  54. models.InitDeliverHooks()
  55. models.InitTestPullRequests()
  56. log.NewGitLogger(path.Join(setting.LogRootPath, "http.log"))
  57. }
  58. if models.EnableSQLite3 {
  59. log.Info("SQLite3 Supported")
  60. }
  61. if models.EnableTiDB {
  62. log.Info("TiDB Supported")
  63. }
  64. checkRunMode()
  65. if setting.InstallLock && setting.SSH.StartBuiltinServer {
  66. ssh.Listen(setting.SSH.ListenHost, setting.SSH.ListenPort)
  67. log.Info("SSH server started on %s:%v", setting.SSH.ListenHost, setting.SSH.ListenPort)
  68. }
  69. }