Beispiel #1
0
// Initialize proxy and tribserver
func initTribserver(storage string, server string, myhostport string) net.Listener {
	// Start proxy
	l, err := net.Listen("tcp", server)
	if err != nil {
		log.Fatal("listen error:", err)
	}
	pc = proxycounter.NewProxyCounter(storage, server)
	if pc == nil {
		fmt.Println("Could not start proxy")
		return nil
	}
	srpc := storagerpc.NewStorageRPC(pc)
	rpc.Register(srpc)
	rpc.HandleHTTP()
	go http.Serve(l, nil)

	// Start tribserver
	ts = tribimpl.NewTribserver(server, myhostport)
	if ts == nil {
		fmt.Println("Could not start tribserver")
		return nil
	}
	rpc.Register(ts)
	return l
}
Beispiel #2
0
// Initialize proxy and libstore
func initLibstore(storage string, server string, myhostport string, flags int) net.Listener {
	// Start proxy
	l, err := net.Listen("tcp", server)
	if err != nil {
		log.Fatal("listen error:", err)
	}
	pc = proxycounter.NewProxyCounter(storage, server)
	if pc == nil {
		fmt.Println("Could not start proxy")
		return nil
	}
	srpc := storagerpc.NewStorageRPC(pc)
	rpc.Register(srpc)
	rpc.HandleHTTP()
	go http.Serve(l, nil)

	// Start libstore
	ls, err = libstore.NewLibstore(server, myhostport, flags)
	if ls == nil || err != nil {
		fmt.Println("Could not start libstore")
		return nil
	}
	return l
}