pserver.go 474 字节
Newer Older
1 2 3 4 5 6 7 8
package main

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

H
Helin Wang 已提交
9 10
	"github.com/namsral/flag"

11
	"github.com/PaddlePaddle/Paddle/go/pserver"
12 13 14
)

func main() {
H
Helin Wang 已提交
15
	port := flag.Int("port", 0, "port of the pserver")
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
	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)
	}
}