2022-11-24 23:37:34 +08:00
|
|
|
// Package cmd
|
|
|
|
// @Link https://github.com/bufanyun/hotgo
|
2023-02-23 17:53:04 +08:00
|
|
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
2022-11-24 23:37:34 +08:00
|
|
|
// @Author Ms <133814250@qq.com>
|
|
|
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"github.com/gogf/gf/v2/os/gcmd"
|
2023-06-05 20:14:57 +08:00
|
|
|
"hotgo/internal/global"
|
2023-02-26 14:18:22 +08:00
|
|
|
"hotgo/internal/library/queue"
|
2023-06-13 15:45:30 +08:00
|
|
|
_ "hotgo/internal/queues"
|
2023-05-10 23:54:50 +08:00
|
|
|
"hotgo/utility/simple"
|
2022-11-24 23:37:34 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
Queue = &gcmd.Command{
|
|
|
|
Name: "queue",
|
|
|
|
Brief: "消息队列",
|
|
|
|
Description: ``,
|
|
|
|
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
|
2023-06-05 20:14:57 +08:00
|
|
|
// 服务日志处理
|
|
|
|
queue.Logger().SetHandlers(global.LoggingServeLogHandler)
|
|
|
|
|
2023-05-10 23:54:50 +08:00
|
|
|
simple.SafeGo(ctx, func(ctx context.Context) {
|
2023-06-05 20:14:57 +08:00
|
|
|
queue.Logger().Debug(ctx, "start queue consumer..")
|
2023-05-10 23:54:50 +08:00
|
|
|
queue.StartConsumersListener(ctx)
|
2023-06-05 20:14:57 +08:00
|
|
|
queue.Logger().Debug(ctx, "start queue consumer success..")
|
2023-05-10 23:54:50 +08:00
|
|
|
})
|
|
|
|
|
2023-05-15 18:37:40 +08:00
|
|
|
serverWg.Add(1)
|
|
|
|
|
2023-05-10 23:54:50 +08:00
|
|
|
// 信号监听
|
|
|
|
signalListen(ctx, signalHandlerForOverall)
|
|
|
|
|
2023-05-30 12:09:40 +08:00
|
|
|
<-serverCloseSignal
|
2023-06-05 20:14:57 +08:00
|
|
|
queue.Logger().Debug(ctx, "queue successfully closed ..")
|
2023-05-30 12:09:40 +08:00
|
|
|
serverWg.Done()
|
2022-11-24 23:37:34 +08:00
|
|
|
return
|
|
|
|
},
|
|
|
|
}
|
|
|
|
)
|