-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
55 lines (46 loc) · 1.25 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"github.com/gofiber/fiber/v2"
"github.com/hitokoto-osc/Moe/config"
"github.com/hitokoto-osc/Moe/flag"
"github.com/hitokoto-osc/Moe/logging"
"github.com/hitokoto-osc/Moe/prestart"
"github.com/hitokoto-osc/Moe/routes"
"go.uber.org/zap"
"runtime"
"github.com/spf13/viper"
)
var (
// BuildTag is a commit hash that will be injected in release mode
BuildTag = "Unknown"
// BuildTime is a time, when it build, that will be injected in release mode
BuildTime = "Unknown"
// CommitTime is a time, when it is committed, that will be injected in release mode
CommitTime = "Unknown"
// Version is the version of this program, will be injected in release mode
Version = "development"
)
var app *fiber.App
func init() {
// Global set build information
config.BuildTag = BuildTag
config.BuildTime = BuildTime
config.GoVersion = runtime.Version()
config.Version = Version
// Parse Flag
flag.Do()
if config.Debug {
logging.GetLogger().Info("Debug mode enabled.")
}
}
func main() {
defer zap.L().Sync()
// Init Drivers
prestart.Do()
// init Web Server
app = routes.InitWebServer()
// start Server
if err := app.Listen(":" + viper.GetString("server.port")); err != nil {
zap.L().Fatal("无法启动服务器", zap.Error(err))
}
}