pserver.go 458 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
package main

import (
	"flag"
	"net"
	"net/http"
	"net/rpc"
	"strconv"

	"github.com/PaddlePaddle/Paddle/paddle/go/pserver"
)

func main() {
	port := flag.Int("p", 0, "port of the pserver")
	flag.Parse()

	s := pserver.NewService()
	err := rpc.Register(s)
	if err != nil {
		panic(err)
	}

	rpc.HandleHTTP()
	l, err := net.Listen("tcp", ":"+strconv.Itoa(*port))
	if err != nil {
		panic(err)
	}

	err = http.Serve(l, nil)
	if err != nil {
		panic(err)
	}
}