hotgo/server/internal/global/init.go

39 lines
1.0 KiB
Go
Raw Normal View History

2022-11-24 23:37:34 +08:00
// 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"
2022-12-11 20:48:18 +08:00
"github.com/gogf/gf/v2"
2022-11-24 23:37:34 +08:00
"github.com/gogf/gf/v2/os/gtime"
2022-12-11 20:48:18 +08:00
"hotgo/internal/consts"
2022-11-24 23:37:34 +08:00
"hotgo/internal/library/location"
2022-11-25 23:22:44 +08:00
"hotgo/utility/simple"
2022-11-24 23:37:34 +08:00
"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()
2022-12-11 20:48:18 +08:00
fmt.Printf("欢迎使用HotGo\r\n当前运行环境%v, 运行根路径为:%v \r\nHotGo版本v%v, gf版本%v \n", SysType, RootPtah, consts.VersionApp, gf.VERSION)
2022-11-24 23:37:34 +08:00
loadMonitor(ctx)
}
func loadMonitor(ctx context.Context) {
2022-11-25 23:22:44 +08:00
simple.SafeGo(ctx, func(ctx context.Context) {
2022-11-24 23:37:34 +08:00
MonitorData.STartTime = gtime.Now()
MonitorData.IntranetIP, _ = location.GetLocalIP()
MonitorData.PublicIP, _ = location.GetPublicIP()
})
}