Files
juwan-backend/app/chat/api/chat.go
T
2026-04-24 21:02:07 +08:00

38 lines
841 B
Go

package main
import (
"flag"
"fmt"
chathandler "juwan-backend/app/chat/api/internal/handler/chat"
"juwan-backend/app/chat/api/internal/config"
"juwan-backend/app/chat/api/internal/svc"
"github.com/wwweww/go-wst/hybrid"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/core/service"
)
var configFile = flag.String("f", "etc/chat-api.yaml", "the config file")
func main() {
flag.Parse()
var c config.Config
conf.MustLoad(*configFile, &c)
svcCtx := svc.NewServiceContext(c)
handler := chathandler.NewHandler(svcCtx)
hybridServer := hybrid.MustNewServer(c.Hybrid, handler)
handler.SetServer(hybridServer)
group := service.NewServiceGroup()
defer group.Stop()
group.Add(hybridServer)
fmt.Printf("Starting chat hybrid server (ws=%s%s)...\n", c.Hybrid.Ws.Addr, c.Hybrid.Ws.Path)
group.Start()
}