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.

main.go 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Copyright 2016 The Gitea Authors. All rights reserved.
  3. // SPDX-License-Identifier: MIT
  4. package main
  5. import (
  6. "os"
  7. "runtime"
  8. "strings"
  9. "time"
  10. "code.gitea.io/gitea/cmd"
  11. "code.gitea.io/gitea/modules/log"
  12. "code.gitea.io/gitea/modules/setting"
  13. // register supported doc types
  14. _ "code.gitea.io/gitea/modules/markup/asciicast"
  15. _ "code.gitea.io/gitea/modules/markup/console"
  16. _ "code.gitea.io/gitea/modules/markup/csv"
  17. _ "code.gitea.io/gitea/modules/markup/markdown"
  18. _ "code.gitea.io/gitea/modules/markup/orgmode"
  19. "github.com/urfave/cli/v2"
  20. )
  21. // these flags will be set by the build flags
  22. var (
  23. Version = "development" // program version for this build
  24. Tags = "" // the Golang build tags
  25. MakeVersion = "" // "make" program version if built with make
  26. )
  27. func init() {
  28. setting.AppVer = Version
  29. setting.AppBuiltWith = formatBuiltWith()
  30. setting.AppStartTime = time.Now().UTC()
  31. }
  32. func main() {
  33. cli.OsExiter = func(code int) {
  34. log.GetManager().Close()
  35. os.Exit(code)
  36. }
  37. app := cmd.NewMainApp(Version, formatBuiltWith())
  38. _ = cmd.RunMainApp(app, os.Args...) // all errors should have been handled by the RunMainApp
  39. log.GetManager().Close()
  40. }
  41. func formatBuiltWith() string {
  42. version := runtime.Version()
  43. if len(MakeVersion) > 0 {
  44. version = MakeVersion + ", " + runtime.Version()
  45. }
  46. if len(Tags) == 0 {
  47. return " built with " + version
  48. }
  49. return " built with " + version + " : " + strings.ReplaceAll(Tags, " ", ", ")
  50. }