Exemplo n.º 1
0
func (g *graphiteTextServiceManager) Start(file *os.File) error {
	var (
		gl  net.Listener
		err error
	)

	if g.listenSpec != "" {
		if file != nil {
			gl, err = net.FileListener(file)
		} else {
			gl, err = net.Listen("tcp", processListenSpec(g.listenSpec))
		}
	} else {
		log.Printf("Not starting Graphite Text protocol because graphite-test-listen-spec is blank")
		return nil
	}

	if err != nil {
		return fmt.Errorf("Error starting Graphite Text Protocol serviceManager: %v", err)
	}

	g.listener = graceful.NewListener(gl)

	fmt.Println("Graphite text protocol Listening on " + processListenSpec(g.listenSpec))

	go g.graphiteTextServer()

	return nil
}
Exemplo n.º 2
0
func (g *wwwServer) Start(file *os.File) error {
	var (
		gl  net.Listener
		err error
	)

	if g.listenSpec != "" {
		if file != nil {
			gl, err = net.FileListener(file)
		} else {
			gl, err = net.Listen("tcp", processListenSpec(g.listenSpec))
		}
	} else {
		log.Printf("Not starting HTTP server because http-listen-spec is blank.")
		return nil
	}

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error starting HTTP protocol: %v\n", err)
		return fmt.Errorf("Error starting HTTP protocol: %v", err)
	}

	g.listener = graceful.NewListener(gl)

	fmt.Printf("HTTP protocol Listening on %s\n", processListenSpec(g.listenSpec))

	go httpServer(g.listenSpec, g.listener, g.rcvr)

	return nil
}