2014-02-19 13:04:31 -05:00
|
|
|
// Copyright 2014 The Gogs Authors. All rights reserved.
|
2016-12-21 10:13:17 -02:00
|
|
|
// Copyright 2016 The Gitea Authors. All rights reserved.
|
2022-11-27 13:20:29 -05:00
|
|
|
// SPDX-License-Identifier: MIT
|
2014-02-12 12:49:46 -05:00
|
|
|
|
2023-07-21 17:28:19 +08:00
|
|
|
package main
|
2014-02-12 12:49:46 -05:00
|
|
|
|
|
|
|
|
import (
|
2014-02-19 17:50:53 +08:00
|
|
|
"os"
|
2019-01-24 16:22:51 +01:00
|
|
|
"runtime"
|
2017-02-28 01:40:02 +01:00
|
|
|
"strings"
|
2020-11-17 23:44:52 +01:00
|
|
|
"time"
|
2016-12-01 00:56:15 +01:00
|
|
|
|
2026-05-26 15:49:31 -07:00
|
|
|
"gitea.dev/cmd"
|
|
|
|
|
"gitea.dev/modules/log"
|
|
|
|
|
"gitea.dev/modules/setting"
|
2018-11-01 13:41:07 +00:00
|
|
|
|
2017-09-21 13:20:14 +08:00
|
|
|
// register supported doc types
|
2026-05-26 15:49:31 -07:00
|
|
|
_ "gitea.dev/modules/markup/asciicast"
|
|
|
|
|
_ "gitea.dev/modules/markup/console"
|
|
|
|
|
_ "gitea.dev/modules/markup/csv"
|
|
|
|
|
_ "gitea.dev/modules/markup/markdown"
|
|
|
|
|
_ "gitea.dev/modules/markup/orgmode"
|
2023-08-05 23:36:45 +08:00
|
|
|
|
2025-06-10 14:35:12 +02:00
|
|
|
"github.com/urfave/cli/v3"
|
2014-02-12 12:49:46 -05:00
|
|
|
)
|
|
|
|
|
|
2023-07-21 17:28:19 +08:00
|
|
|
// these flags will be set by the build flags
|
2019-04-03 00:10:11 +08:00
|
|
|
var (
|
2026-02-19 02:23:32 +01:00
|
|
|
Version = "development" // program version for this build
|
|
|
|
|
Tags = "" // the Golang build tags
|
2019-04-03 00:10:11 +08:00
|
|
|
)
|
2017-02-28 01:40:02 +01:00
|
|
|
|
2014-02-12 14:54:09 -05:00
|
|
|
func init() {
|
2016-11-04 12:32:04 +01:00
|
|
|
setting.AppVer = Version
|
2019-06-12 21:41:28 +02:00
|
|
|
setting.AppBuiltWith = formatBuiltWith()
|
2020-11-17 23:44:52 +01:00
|
|
|
setting.AppStartTime = time.Now().UTC()
|
2023-06-21 13:50:26 +08:00
|
|
|
}
|
2019-04-29 19:08:21 +01:00
|
|
|
|
2014-02-12 12:49:46 -05:00
|
|
|
func main() {
|
2023-08-05 23:36:45 +08:00
|
|
|
cli.OsExiter = func(code int) {
|
|
|
|
|
log.GetManager().Close()
|
|
|
|
|
os.Exit(code)
|
2016-12-01 00:56:15 +01:00
|
|
|
}
|
2024-04-27 20:23:37 +08:00
|
|
|
app := cmd.NewMainApp(cmd.AppVersion{Version: Version, Extra: formatBuiltWith()})
|
2023-08-05 23:36:45 +08:00
|
|
|
_ = cmd.RunMainApp(app, os.Args...) // all errors should have been handled by the RunMainApp
|
2025-10-25 00:02:58 -07:00
|
|
|
// flush the queued logs before exiting, it is a MUST, otherwise there will be log loss
|
2023-05-22 06:35:11 +08:00
|
|
|
log.GetManager().Close()
|
2014-02-12 12:49:46 -05:00
|
|
|
}
|
2017-02-28 01:40:02 +01:00
|
|
|
|
2019-06-12 21:41:28 +02:00
|
|
|
func formatBuiltWith() string {
|
2022-01-20 18:46:10 +01:00
|
|
|
version := runtime.Version()
|
2017-02-28 01:40:02 +01:00
|
|
|
if len(Tags) == 0 {
|
2019-04-03 00:10:11 +08:00
|
|
|
return " built with " + version
|
2017-02-28 01:40:02 +01:00
|
|
|
}
|
|
|
|
|
|
2020-10-11 22:27:20 +02:00
|
|
|
return " built with " + version + " : " + strings.ReplaceAll(Tags, " ", ", ")
|
2017-02-28 01:40:02 +01:00
|
|
|
}
|