2023-07-24 08:07:05 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-09-04 06:26:55 +00:00
|
|
|
"context"
|
2023-07-24 08:07:05 +00:00
|
|
|
"flag"
|
|
|
|
"fmt"
|
2023-09-04 06:26:55 +00:00
|
|
|
"fusenapi/server/websocket/internal/logic"
|
2023-07-24 08:07:05 +00:00
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"fusenapi/utils/auth"
|
|
|
|
|
|
|
|
"fusenapi/server/websocket/internal/config"
|
|
|
|
"fusenapi/server/websocket/internal/handler"
|
|
|
|
"fusenapi/server/websocket/internal/svc"
|
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/conf"
|
|
|
|
"github.com/zeromicro/go-zero/rest"
|
|
|
|
)
|
|
|
|
|
|
|
|
var configFile = flag.String("f", "etc/websocket.yaml", "the config file")
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
var c config.Config
|
|
|
|
conf.MustLoad(*configFile, &c)
|
|
|
|
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
|
|
|
}))
|
|
|
|
defer server.Stop()
|
|
|
|
|
|
|
|
ctx := svc.NewServiceContext(c)
|
|
|
|
handler.RegisterHandlers(server, ctx)
|
2023-09-04 06:26:55 +00:00
|
|
|
ctx1 := context.Background()
|
|
|
|
ctx1, cancel := context.WithCancel(ctx1)
|
|
|
|
defer cancel()
|
|
|
|
//消费公共通知队列的数据
|
|
|
|
go logic.ConsumeCommonCacheData(ctx1)
|
|
|
|
//消费用户索引创建/删除/发送消息中的任务数据
|
2023-09-07 01:59:57 +00:00
|
|
|
go logic.ConsumeUserConnPoolCtlChanData(ctx1)
|
2023-09-07 07:54:24 +00:00
|
|
|
//消费连接统计信息
|
|
|
|
go logic.ConsumeWebsocketConnectCountCtlChanData(ctx1)
|
2023-07-24 08:07:05 +00:00
|
|
|
fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
|
|
|
|
server.Start()
|
|
|
|
}
|