2026-03-14 10:02:49 +08:00
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"context"
|
2026-04-11 18:22:52 +08:00
|
|
|
|
"customer-server/consts/public"
|
2026-03-14 10:02:49 +08:00
|
|
|
|
"customer-server/controller"
|
|
|
|
|
|
"customer-server/service"
|
|
|
|
|
|
"os"
|
|
|
|
|
|
"os/signal"
|
|
|
|
|
|
"syscall"
|
|
|
|
|
|
|
2026-04-09 16:14:31 +08:00
|
|
|
|
_ "gitea.com/red-future/common/config"
|
2026-03-14 10:02:49 +08:00
|
|
|
|
"gitea.com/red-future/common/http"
|
|
|
|
|
|
"gitea.com/red-future/common/jaeger"
|
2026-04-11 18:22:52 +08:00
|
|
|
|
"gitea.com/red-future/common/utils"
|
|
|
|
|
|
gmq "github.com/bjang03/gmq/core/gmq"
|
|
|
|
|
|
"github.com/bjang03/gmq/mq"
|
|
|
|
|
|
"github.com/bjang03/gmq/types"
|
2026-04-03 17:52:09 +08:00
|
|
|
|
_ "github.com/gogf/gf/contrib/drivers/pgsql/v2"
|
2026-03-14 10:02:49 +08:00
|
|
|
|
_ "github.com/gogf/gf/contrib/nosql/redis/v2"
|
|
|
|
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
|
|
|
|
"github.com/gogf/gf/v2/os/glog"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
|
ctx := context.Background()
|
|
|
|
|
|
defer jaeger.ShutDown(ctx)
|
|
|
|
|
|
|
|
|
|
|
|
// 路由注册(common/http init() 已异步启动服务器,这里注册路由不影响)
|
|
|
|
|
|
http.RouteRegister([]interface{}{
|
2026-04-03 17:52:09 +08:00
|
|
|
|
controller.Account,
|
|
|
|
|
|
controller.ScriptedSpeech,
|
|
|
|
|
|
controller.AccountWebsocket,
|
2026-04-11 18:22:52 +08:00
|
|
|
|
controller.AccountHttp,
|
2026-03-14 10:02:49 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
2026-04-11 18:22:52 +08:00
|
|
|
|
if err := utils.InitGseTool(ctx); err != nil {
|
|
|
|
|
|
g.Log().Error(ctx, "gse 分词工具初始化失败:", err)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gmq.GmqRegister(public.GmqMsgPluginsName, &mq.NatsConn{
|
|
|
|
|
|
NatsConfig: mq.NatsConfig{
|
|
|
|
|
|
Addr: g.Cfg().MustGet(ctx, "nats.default.addr").String(),
|
|
|
|
|
|
Port: g.Cfg().MustGet(ctx, "nats.default.port").String(),
|
|
|
|
|
|
},
|
|
|
|
|
|
})
|
|
|
|
|
|
if err := gmq.GetGmq(public.GmqMsgPluginsName).GmqSubscribe(ctx, &mq.NatsSubMessage{
|
|
|
|
|
|
SubMessage: types.SubMessage{
|
|
|
|
|
|
Topic: public.AccountFollowupTopic,
|
|
|
|
|
|
ConsumerName: public.AccountFollowupConsumer,
|
|
|
|
|
|
AutoAck: public.AccountFollowupAck,
|
|
|
|
|
|
FetchCount: public.AccountFollowupCount,
|
|
|
|
|
|
HandleFunc: service.AccountWebSocket.AccountMsg,
|
|
|
|
|
|
},
|
|
|
|
|
|
IsDelayMsg: true,
|
|
|
|
|
|
}); err != nil {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2026-03-14 10:02:49 +08:00
|
|
|
|
|
|
|
|
|
|
// 监听系统信号,支持 Ctrl+C 优雅退出
|
|
|
|
|
|
quit := make(chan os.Signal, 1)
|
|
|
|
|
|
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
|
|
|
|
|
<-quit
|
|
|
|
|
|
|
2026-04-11 18:22:52 +08:00
|
|
|
|
glog.Info(ctx, "正在关闭服务...")
|
2026-03-14 10:02:49 +08:00
|
|
|
|
|
|
|
|
|
|
}
|