1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- package main
- import (
- "app.yhyue.com/moapp/jybase/go-logger/logger"
- _ "app.yhyue.com/moapp/message/config"
- "app.yhyue.com/moapp/message/handler"
- "app.yhyue.com/moapp/message/services"
- "github.com/gogf/gf/v2/os/gcfg"
- "github.com/gogf/gf/v2/os/gctx"
- "github.com/nsqio/go-nsq"
- "log"
- )
- func init() {
- logger.SetConsole(false)
- logger.SetRollingDaily("./logs", "message.log")
- }
- func nsqWork() {
- // Instantiate a consumer that will subscribe to the provided channel.
- config := nsq.NewConfig()
- consumer, err := nsq.NewConsumer("jy_event", "event", config)
- if err != nil {
- log.Fatal(err)
- }
- // Set the Handler for messages received by this Consumer. Can be called multiple times.
- // See also AddConcurrentHandlers.
- consumer.AddHandler(&handler.Handler{})
- // Use nsqlookupd to discover nsqd instances.
- // See also ConnectToNSQD, ConnectToNSQDs, ConnectToNSQLookupds.
- err = consumer.ConnectToNSQLookupd(gcfg.Instance().MustGet(gctx.New(), "nsq.address", "").String())
- if err != nil {
- log.Fatal(err)
- }
- // Gracefully stop the consumer.
- //consumer.Stop()
- select {}
- }
- //
- func main() {
- go nsqWork()
- /*//注册代理服务
- gateWayEtcd := gcfg.Instance().MustGet(gctx.New(), "etcd.gateway.address", "").Strings()
- gateWayServerCode := gcfg.Instance().MustGet(gctx.New(), "etcd.gateway.serverCode", "").String()
- gateWayServerPort := gcfg.Instance().MustGet(gctx.New(), "server.address", "").String()
- closeNotify, err := node.NewNode(gateWayEtcd...).Register(gateWayServerCode, gateWayServerPort)
- if err != nil {
- panic(err)
- }
- //启动服务
- go func() {*/
- services.InitActivityServer().Run()
- /*}()
- quit := make(chan os.Signal, 1)
- signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
- <-quit
- closeNotify()*/
- }
|