mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-26 16:46:14 +08:00
更新gf版本到v2.2.4
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gcmd"
|
||||
"github.com/gogf/gf/v2/os/grpool"
|
||||
"hotgo/utility/simple"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -20,13 +20,13 @@ var (
|
||||
欢迎使用HotGo!
|
||||
---------------------------------------------------------------------------------
|
||||
启动服务
|
||||
>> HTTP服务 [gf run main.go --args "http"]
|
||||
>> 消息队列 [gf run main.go --args "queue"]
|
||||
>> 所有服务 [gf run main.go --args "all"]
|
||||
>> HTTP服务 [go run main.go http]
|
||||
>> 消息队列 [go run main.go queue]
|
||||
>> 所有服务 [go run main.go all]
|
||||
|
||||
---------------------------------------------------------------------------------
|
||||
工具
|
||||
>> 释放casbin权限,用于清理无效的权限设置 [gf run main.go --args "tools -m=casbin -a1=refresh"]
|
||||
>> 释放casbin权限,用于清理无效的权限设置 [go run main.go tools -m=casbin -a1=refresh]
|
||||
`,
|
||||
}
|
||||
|
||||
@@ -46,22 +46,17 @@ var (
|
||||
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
|
||||
g.Log().Info(ctx, "start all server")
|
||||
|
||||
if err = grpool.AddWithRecover(ctx, func(ctx context.Context) {
|
||||
simple.SafeGo(ctx, func(ctx context.Context) {
|
||||
if err := Http.Func(ctx, parser); err != nil {
|
||||
g.Log().Fatal(ctx, "http server start fail:", err)
|
||||
}
|
||||
}); err != nil {
|
||||
return
|
||||
}
|
||||
})
|
||||
|
||||
if err = grpool.AddWithRecover(ctx, func(ctx context.Context) {
|
||||
simple.SafeGo(ctx, func(ctx context.Context) {
|
||||
if err := Queue.Func(ctx, parser); err != nil {
|
||||
g.Log().Fatal(ctx, "queue consumer start fail:", err)
|
||||
}
|
||||
}); err != nil {
|
||||
g.Log().Fatal(ctx, "queue consumer start fail2:", err)
|
||||
return
|
||||
}
|
||||
})
|
||||
|
||||
// 信号监听
|
||||
signalListen(ctx, signalHandlerForOverall)
|
||||
|
@@ -8,11 +8,10 @@ package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gproc"
|
||||
"github.com/gogf/gf/v2/os/grpool"
|
||||
"hotgo/internal/crons"
|
||||
"hotgo/internal/websocket"
|
||||
"hotgo/utility/simple"
|
||||
"os"
|
||||
)
|
||||
|
||||
@@ -29,12 +28,9 @@ func signalHandlerForOverall(sig os.Signal) {
|
||||
}
|
||||
|
||||
func signalListen(ctx context.Context, handler ...gproc.SigHandler) {
|
||||
err := grpool.AddWithRecover(ctx, func(ctx context.Context) {
|
||||
simple.SafeGo(ctx, func(ctx context.Context) {
|
||||
gproc.AddSigHandlerShutdown(handler...)
|
||||
gproc.Listen()
|
||||
})
|
||||
if err != nil {
|
||||
g.Log().Fatal(ctx, "signalListen Fatal:", err)
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -10,11 +10,11 @@ import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/grpool"
|
||||
"hotgo/api/backend/monitor"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/model/input/form"
|
||||
"hotgo/internal/websocket"
|
||||
"hotgo/utility/simple"
|
||||
"hotgo/utility/useragent"
|
||||
"sort"
|
||||
)
|
||||
@@ -36,13 +36,11 @@ func (c *cMonitor) Offline(ctx context.Context, req *monitor.OfflineReq) (res *m
|
||||
return
|
||||
}
|
||||
|
||||
err = grpool.AddWithRecover(ctx, func(ctx context.Context) {
|
||||
simple.SafeGo(ctx, func(ctx context.Context) {
|
||||
websocket.SendSuccess(client, "kick")
|
||||
websocket.Close(client)
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
|
@@ -9,10 +9,9 @@ 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"
|
||||
"hotgo/utility/simple"
|
||||
"os"
|
||||
)
|
||||
|
||||
@@ -29,14 +28,9 @@ func Init(ctx context.Context) {
|
||||
}
|
||||
|
||||
func loadMonitor(ctx context.Context) {
|
||||
err := grpool.AddWithRecover(ctx, func(ctx context.Context) {
|
||||
simple.SafeGo(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
|
||||
}
|
||||
}
|
||||
|
@@ -9,7 +9,6 @@ package admin
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/os/grpool"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/dao"
|
||||
@@ -18,6 +17,7 @@ import (
|
||||
"hotgo/internal/websocket"
|
||||
"hotgo/utility/charset"
|
||||
"hotgo/utility/convert"
|
||||
"hotgo/utility/simple"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -75,7 +75,7 @@ func (s *sAdminNotice) Edit(ctx context.Context, in adminin.NoticeEditInp) (err
|
||||
Event: "notice",
|
||||
Data: in,
|
||||
}
|
||||
grpool.AddWithRecover(ctx, func(ctx context.Context) {
|
||||
simple.SafeGo(ctx, func(ctx context.Context) {
|
||||
if len(memberIds) == 0 {
|
||||
websocket.SendToAll(response)
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user