fusenapi/server/websocket/websocket.go

42 lines
1.0 KiB
Go
Raw Normal View History

2023-07-24 08:07:05 +00:00
package main
import (
2023-08-04 09:45:36 +00:00
"context"
2023-07-24 08:07:05 +00:00
"flag"
"fmt"
2023-08-04 09:45:36 +00:00
"fusenapi/constants"
2023-08-07 04:31:31 +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)
2023-08-07 03:15:51 +00:00
//消费渲染结果队列
2023-08-04 09:45:36 +00:00
ctx1 := context.Background()
ctx2, cancel := context.WithCancel(ctx1)
defer cancel()
2023-08-07 04:31:31 +00:00
go ctx.RabbitMq.Consume(ctx2, constants.RABBIT_MQ_RENDER_RESULT_DATA, &logic.MqConsumerRenderResult{})
2023-07-24 08:07:05 +00:00
handler.RegisterHandlers(server, ctx)
fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
server.Start()
}