add: chat service
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
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()
|
||||
}
|
||||
Reference in New Issue
Block a user