mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-28 05:12:32 +08:00
v2.0
This commit is contained in:
42
server/internal/global/init.go
Normal file
42
server/internal/global/init.go
Normal file
@@ -0,0 +1,42 @@
|
||||
// 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/frame/g"
|
||||
"github.com/gogf/gf/v2/os/grpool"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"hotgo/internal/library/location"
|
||||
"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\n", SysType, RootPtah)
|
||||
loadMonitor(ctx)
|
||||
}
|
||||
|
||||
func loadMonitor(ctx context.Context) {
|
||||
err := grpool.AddWithRecover(ctx, func(ctx context.Context) {
|
||||
MonitorData.STartTime = gtime.Now()
|
||||
MonitorData.IntranetIP, _ = location.GetLocalIP()
|
||||
MonitorData.PublicIP, _ = location.GetPublicIP()
|
||||
|
||||
})
|
||||
if err != nil {
|
||||
g.Log().Fatal(ctx, "global loadMonitor Fatal:", err)
|
||||
return
|
||||
}
|
||||
}
|
21
server/internal/global/static.go
Normal file
21
server/internal/global/static.go
Normal file
@@ -0,0 +1,21 @@
|
||||
// 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 (
|
||||
"hotgo/internal/model"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
var (
|
||||
// RootPtah 运行根路径
|
||||
RootPtah string
|
||||
// SysType 操作系统类型 windows | linux
|
||||
SysType = runtime.GOOS
|
||||
// MonitorData 监控数据
|
||||
MonitorData model.MonitorData
|
||||
)
|
Reference in New Issue
Block a user