mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-12-12 11:16:05 +08:00
模块化定时任务,方便在插件中注册任务;增加日志分组
This commit is contained in:
@@ -50,7 +50,6 @@ func (c *cCash) List(ctx context.Context, req *cash.ListReq) (res *cash.ListRes,
|
||||
res.PageCount = form.CalPageCount(totalCount, req.PerPage)
|
||||
res.Page = req.Page
|
||||
res.PerPage = req.PerPage
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ func (c *cMonitor) Offline(ctx context.Context, req *monitor.OfflineReq) (res *m
|
||||
websocket.SendSuccess(client, "kick")
|
||||
websocket.Close(client)
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -94,18 +93,17 @@ func (c *cMonitor) OnlineList(ctx context.Context, req *monitor.OnlineListReq) (
|
||||
res.PerPage = req.PerPage
|
||||
|
||||
sort.Sort(monitor.OnlineModels(clients))
|
||||
isDemo := g.Cfg().MustGet(ctx, "hotgo.isDemo", false)
|
||||
isDemo := g.Cfg().MustGet(ctx, "hotgo.isDemo", false).Bool()
|
||||
_, perPage, offset := form.CalPage(ctx, req.Page, req.PerPage)
|
||||
|
||||
for k, v := range clients {
|
||||
if k >= offset && i <= perPage {
|
||||
if isDemo.Bool() {
|
||||
if isDemo {
|
||||
v.Addr = consts.DemoTips
|
||||
}
|
||||
res.List = append(res.List, v)
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ type cConsole struct{}
|
||||
func (c *cConsole) Stat(_ context.Context, _ *common.ConsoleStatReq) (res *common.ConsoleStatRes, err error) {
|
||||
res = new(common.ConsoleStatRes)
|
||||
|
||||
// 此处均为模拟数据,可以根据实际业务情况替换成真实数据
|
||||
|
||||
res.Visits.DayVisits = 12010
|
||||
res.Visits.Rise = 13501
|
||||
res.Visits.Decline = 10502
|
||||
|
||||
@@ -24,7 +24,6 @@ func (c *cUpload) UploadImage(ctx context.Context, _ *common.UploadImageReq) (re
|
||||
err = gerror.New("没有找到上传的文件")
|
||||
return
|
||||
}
|
||||
|
||||
return service.CommonUpload().UploadImage(ctx, file)
|
||||
}
|
||||
|
||||
@@ -35,6 +34,5 @@ func (c *cUpload) UploadFile(ctx context.Context, _ *common.UploadFileReq) (res
|
||||
err = gerror.New("没有找到上传的文件")
|
||||
return
|
||||
}
|
||||
|
||||
return service.CommonUpload().UploadFile(ctx, file)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package sys
|
||||
|
||||
import (
|
||||
@@ -94,6 +93,5 @@ func (c *cDictData) Selects(ctx context.Context, req *dict.DataSelectsReq) (res
|
||||
}
|
||||
res[v] = option
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ func (c *cNotify) WxPay(ctx context.Context, _ *pay.NotifyWxPayReq) (res *pay.No
|
||||
}
|
||||
|
||||
res = &pay.NotifyWxPayRes{PayType: consts.PayTypeWxPay, Code: "SUCCESS", Message: "收单成功"}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
"hotgo/utility/format"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -77,8 +76,8 @@ func (c *cMonitor) RunInfo(client *websocket.Client, req *websocket.WRequest) {
|
||||
"goSize": file.DirSize(pwd),
|
||||
}
|
||||
|
||||
isDemo := g.Cfg().MustGet(client.Context(), "hotgo.isDemo", false)
|
||||
if isDemo.Bool() {
|
||||
isDemo := g.Cfg().MustGet(client.Context(), "hotgo.isDemo", false).Bool()
|
||||
if isDemo {
|
||||
data["rootPath"] = consts.DemoTips
|
||||
data["pwd"] = consts.DemoTips
|
||||
data["intranet_ip"] = consts.DemoTips
|
||||
@@ -104,7 +103,7 @@ func (c *cMonitor) Trends(client *websocket.Client, req *websocket.WRequest) {
|
||||
mMem, memErr = mem.VirtualMemory()
|
||||
mMemUsed float64
|
||||
mDisk, diskErr = disk.Usage("/")
|
||||
mProcess, ProcessErr = process.Pids()
|
||||
mProcess, processErr = process.Pids()
|
||||
mLoadAvg = new(model.LoadAvgStats)
|
||||
monitorHeads []MonitorHead
|
||||
nets []NetC
|
||||
@@ -112,32 +111,32 @@ func (c *cMonitor) Trends(client *websocket.Client, req *websocket.WRequest) {
|
||||
)
|
||||
|
||||
if cpuErr != nil {
|
||||
g.Log().Infof(client.Context(), "read CPU info fail:%+v", cpuErr)
|
||||
g.Log().Warningf(client.Context(), "read CPU info fail:%+v", cpuErr)
|
||||
mCpu = []cpu.InfoStat{{VendorID: "", ModelName: ""}}
|
||||
}
|
||||
|
||||
if memErr != nil {
|
||||
g.Log().Infof(client.Context(), "read mem info fail:%+v", memErr)
|
||||
g.Log().Warningf(client.Context(), "read mem info fail:%+v", memErr)
|
||||
mMem = new(mem.VirtualMemoryStat)
|
||||
}
|
||||
|
||||
if diskErr != nil {
|
||||
g.Log().Infof(client.Context(), "read disk info fail:%+v", diskErr)
|
||||
g.Log().Warningf(client.Context(), "read disk info fail:%+v", diskErr)
|
||||
mDisk = new(disk.UsageStat)
|
||||
}
|
||||
|
||||
if ProcessErr != nil {
|
||||
g.Log().Infof(client.Context(), "read process.Pids fail:%+v", ProcessErr)
|
||||
if processErr != nil {
|
||||
g.Log().Warningf(client.Context(), "read process.Pids fail:%+v", processErr)
|
||||
}
|
||||
|
||||
// cpu使用率
|
||||
cu, err := cpu.Percent(time.Second, false)
|
||||
if err == nil {
|
||||
mCpuUsed, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cu[0]), 64)
|
||||
mCpuUsed = gconv.Float64(fmt.Sprintf("%.2f", cu[0]))
|
||||
}
|
||||
|
||||
// 内存使用率
|
||||
mMemUsed, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", mMem.UsedPercent), 64)
|
||||
mMemUsed = gconv.Float64(fmt.Sprintf("%.2f", mMem.UsedPercent))
|
||||
|
||||
// 负载
|
||||
if len(meta.LoadAvg) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user