Files
m8sh/main.go
T

58 lines
1.4 KiB
Go
Raw Normal View History

2014-02-19 13:04:31 -05:00
// Copyright 2014 The Gogs Authors. All rights reserved.
// Copyright 2016 The Gitea Authors. All rights reserved.
// 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"
"time"
2016-12-01 00:56:15 +01:00
"gitea.dev/cmd"
"gitea.dev/modules/log"
"gitea.dev/modules/setting"
2018-11-01 13:41:07 +00:00
// register supported doc types
_ "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"
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 (
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()
setting.AppStartTime = time.Now().UTC()
2023-06-21 13:50:26 +08:00
}
2014-02-12 12:49:46 -05:00
func main() {
cli.OsExiter = func(code int) {
log.GetManager().Close()
os.Exit(code)
2016-12-01 00:56:15 +01:00
}
app := cmd.NewMainApp(cmd.AppVersion{Version: Version, Extra: formatBuiltWith()})
_ = 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
}
return " built with " + version + " : " + strings.ReplaceAll(Tags, " ", ", ")
2017-02-28 01:40:02 +01:00
}