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() { ctx := &Context{l} tcpListener, err := net.Listen("tcp", l.tcpAddr.String()) if err != nil { l.logf("FATAL: listen (%s) failed - %s", l.tcpAddr, err) os.Exit(1) } l.tcpListener = tcpListener tcpServer := &tcpServer{ctx: ctx} l.waitGroup.Wrap(func() { util.TCPServer(tcpListener, tcpServer, l.opts.Logger) }) httpListener, err := net.Listen("tcp", l.httpAddr.String()) if err != nil { l.logf("FATAL: listen (%s) failed - %s", l.httpAddr, err) os.Exit(1) } l.httpListener = httpListener httpServer := &httpServer{ctx: ctx} l.waitGroup.Wrap(func() { util.HTTPServer(httpListener, httpServer, l.opts.Logger, "HTTP") }) }
func (n *NSQD) Main() { var httpListener net.Listener var httpsListener net.Listener ctx := &context{n} n.waitGroup.Wrap(func() { n.lookupLoop() }) tcpListener, err := net.Listen("tcp", n.tcpAddr.String()) if err != nil { n.logf("FATAL: listen (%s) failed - %s", n.tcpAddr, err) os.Exit(1) } n.tcpListener = tcpListener tcpServer := &tcpServer{ctx: ctx} n.waitGroup.Wrap(func() { util.TCPServer(n.tcpListener, tcpServer, n.opts.Logger) }) if n.tlsConfig != nil && n.httpsAddr != nil { httpsListener, err = tls.Listen("tcp", n.httpsAddr.String(), n.tlsConfig) if err != nil { n.logf("FATAL: listen (%s) failed - %s", n.httpsAddr, err) os.Exit(1) } n.httpsListener = httpsListener httpsServer := &httpServer{ ctx: ctx, tlsEnabled: true, tlsRequired: true, } n.waitGroup.Wrap(func() { util.HTTPServer(n.httpsListener, httpsServer, n.opts.Logger, "HTTPS") }) } httpListener, err = net.Listen("tcp", n.httpAddr.String()) if err != nil { n.logf("FATAL: listen (%s) failed - %s", n.httpAddr, err) os.Exit(1) } n.httpListener = httpListener httpServer := &httpServer{ ctx: ctx, tlsEnabled: false, tlsRequired: n.opts.TLSRequired, } n.waitGroup.Wrap(func() { util.HTTPServer(n.httpListener, httpServer, n.opts.Logger, "HTTP") }) if n.opts.StatsdAddress != "" { n.waitGroup.Wrap(func() { n.statsdLoop() }) } }
func (n *NSQD) Main() { var httpListener net.Listener var httpsListener net.Listener context := &context{n} if n.options.TLSClientAuthPolicy != "" { n.options.TLSRequired = true } if n.tlsConfig == nil && n.options.TLSRequired { log.Fatalf("FATAL: cannot require TLS client connections without TLS key and cert") } 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) }) if n.tlsConfig != nil && n.httpsAddr != nil { httpsListener, err = tls.Listen("tcp", n.httpsAddr.String(), n.tlsConfig) if err != nil { log.Fatalf("FATAL: listen (%s) failed - %s", n.httpsAddr, err.Error()) } n.httpsListener = httpsListener httpsServer := &httpServer{ context: context, tlsEnabled: true, tlsRequired: true, } n.waitGroup.Wrap(func() { util.HTTPServer(n.httpsListener, httpsServer, "HTTPS") }) } 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, tlsEnabled: false, tlsRequired: n.options.TLSRequired, } n.waitGroup.Wrap(func() { util.HTTPServer(n.httpListener, httpServer, "HTTP") }) 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, "HTTP") }) }