func (n *NSQd) Main() { context := &Context{n} n.waitGroup.Wrap(func() { n.lookupLoop() }) tcpListener, err := net.Listen("tcp", n.tcpAddr.String()) if err != nil { log.Fatalf("FATAL: listen (%s) failed - %s", n.tcpAddr, err.Error()) } n.tcpListener = tcpListener tcpServer := &tcpServer{context: context} n.waitGroup.Wrap(func() { util.TCPServer(n.tcpListener, tcpServer) }) httpListener, err := net.Listen("tcp", n.httpAddr.String()) if err != nil { log.Fatalf("FATAL: listen (%s) failed - %s", n.httpAddr, err.Error()) } n.httpListener = httpListener httpServer := &httpServer{context: context} n.waitGroup.Wrap(func() { util.HTTPServer(n.httpListener, httpServer) }) if n.options.statsdAddress != "" { n.waitGroup.Wrap(func() { n.statsdLoop() }) } }
func (l *NSQLookupd) Main() { context := &Context{l} tcpListener, err := net.Listen("tcp", l.tcpAddr.String()) if err != nil { log.Fatalf("FATAL: listen (%s) failed - %s", l.tcpAddr, err.Error()) } l.tcpListener = tcpListener tcpServer := &tcpServer{context: context} l.waitGroup.Wrap(func() { util.TCPServer(tcpListener, tcpServer) }) httpListener, err := net.Listen("tcp", l.httpAddr.String()) if err != nil { log.Fatalf("FATAL: listen (%s) failed - %s", l.httpAddr, err.Error()) } l.httpListener = httpListener httpServer := &httpServer{context: context} l.waitGroup.Wrap(func() { util.HTTPServer(httpListener, httpServer) }) }