Exemplo n.º 1
0
// ListenAndServe implements the ListenAndServe interface
func (s *UnitedAdmin) ListenAndServe() error {
	addr := utils.Addrcat(s.host, s.port)
	l, err := net.Listen("tcp", addr)
	if err != nil {
		return err
	}

	stopListener, err := utils.NewStopListener(l)
	if err != nil {
		return err
	}
	s.stopListener = stopListener

	log.Printf("admin server serving at %s...", addr)
	return s.server.Serve(s.stopListener)
}
Exemplo n.º 2
0
// ListenAndServe implements the ListenAndServe interface
func (h *HTTPEntry) ListenAndServe() error {
	addr := utils.Addrcat(h.host, h.port)
	l, err := net.Listen("tcp", addr)
	if err != nil {
		return err
	}

	stopListener, err := utils.NewStopListener(l)
	if err != nil {
		return err
	}
	h.stopListener = stopListener

	log.Printf("http entrance serving at %s...", addr)
	return h.server.Serve(h.stopListener)
}
Exemplo n.º 3
0
// ListenAndServe implements the ListenAndServe interface
func (r *RedisEntry) ListenAndServe() error {
	addr := utils.Addrcat(r.host, r.port)
	l, err := net.Listen("tcp", addr)
	if err != nil {
		return err
	}

	stopListener, err := utils.NewStopListener(l)
	if err != nil {
		return err
	}
	r.stopListener = stopListener

	log.Printf("redis entrance serving at %s...", addr)
	for {
		conn, err := r.stopListener.Accept()
		if err != nil {
			// log.Printf("Accept failed: %s\n", err)
			return err
		}
		go r.handlerConn(newSession(conn))
	}
}
Exemplo n.º 4
0
// ListenAndServe implements the ListenAndServe interface
func (m *McEntry) ListenAndServe() error {
	addr := utils.Addrcat(m.host, m.port)
	l, err := net.Listen("tcp", addr)
	if err != nil {
		return err
	}

	stopListener, err := utils.NewStopListener(l)
	if err != nil {
		return err
	}
	m.stopListener = stopListener

	log.Printf("mc entrance serving at %s...", addr)
	for {
		conn, e := m.stopListener.Accept()
		if e != nil {
			// log.Printf("Accept failed: %s\n", e)
			return e
		}

		go m.handlerConn(conn)
	}
}