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.

cmd.go 991B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright 2018 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 cmd provides subcommands to the gitea binary - such as "web" or
  5. // "admin".
  6. package cmd
  7. import (
  8. "errors"
  9. "fmt"
  10. "code.gitea.io/gitea/models"
  11. "code.gitea.io/gitea/modules/setting"
  12. "github.com/urfave/cli"
  13. )
  14. // argsSet checks that all the required arguments are set. args is a list of
  15. // arguments that must be set in the passed Context.
  16. func argsSet(c *cli.Context, args ...string) error {
  17. for _, a := range args {
  18. if !c.IsSet(a) {
  19. return errors.New(a + " is not set")
  20. }
  21. }
  22. return nil
  23. }
  24. func initDB() error {
  25. return initDBDisableConsole(false)
  26. }
  27. func initDBDisableConsole(disableConsole bool) error {
  28. setting.NewContext()
  29. models.LoadConfigs()
  30. setting.NewXORMLogService(disableConsole)
  31. if err := models.SetEngine(); err != nil {
  32. return fmt.Errorf("models.SetEngine: %v", err)
  33. }
  34. return nil
  35. }