hotgo/server/internal/global/init.go
2022-12-11 20:48:18 +08:00

39 lines
1.0 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Package global
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2022 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
//
package global
import (
"context"
"fmt"
"github.com/gogf/gf/v2"
"github.com/gogf/gf/v2/os/gtime"
"hotgo/internal/consts"
"hotgo/internal/library/location"
"hotgo/utility/simple"
"os"
)
func Init(ctx context.Context) {
// 默认上海时区
if err := gtime.SetTimeZone("Asia/Shanghai"); err != nil {
fmt.Printf("时区设置异常err%v \r\n", err)
return
}
RootPtah, _ = os.Getwd()
fmt.Printf("欢迎使用HotGo\r\n当前运行环境%v, 运行根路径为:%v \r\nHotGo版本v%v, gf版本%v \n", SysType, RootPtah, consts.VersionApp, gf.VERSION)
loadMonitor(ctx)
}
func loadMonitor(ctx context.Context) {
simple.SafeGo(ctx, func(ctx context.Context) {
MonitorData.STartTime = gtime.Now()
MonitorData.IntranetIP, _ = location.GetLocalIP()
MonitorData.PublicIP, _ = location.GetPublicIP()
})
}