func main() { log.Println("Starting Server") arith := new(Arith) rpc.Register(arith) rpc.Register(&Server{}) go serveUDP(":1234") go serveTCP(":1234") go serveTLS(":1235") serveHTTP(":1236") }
func main() { // Pull in command line options or defaults if none given flag.Parse() f, err := os.OpenFile(*skylib.LogFileName, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666) if err == nil { defer f.Close() log.SetOutput(f) } skylib.Setup(sName) r := NewGetUserDataService() rpc.Register(r) rpc.HandleHTTP() portString := fmt.Sprintf("%s:%d", *skylib.BindIP, *skylib.Port) l, e := net.Listen("tcp", portString) if e != nil { log.Fatal("listen error:", e) } log.Println("Starting server") http.Serve(l, nil) }
func main() { flag.Parse() rpc.Register(server) rpc.HandleHTTP() http.HandleFunc("/", Static) http.HandleFunc("/get", Get) http.ListenAndServe(*listenAddr, nil) }
func main() { arith := new(arith.Arith) rpc.Register(arith) rpc.HandleHTTP() l, e := net.Listen("tcp", ":1234") if e != nil { log.Exit("listen error: ", e) } http.Serve(l, nil) }
func server() { ps := new(ProcessStarter) rpc.Register(ps) rpc.HandleHTTP() l, e := net.Listen("tcp", ":1234") if e != nil { log.Exit("listen error:", e) } go http.Serve(l, nil) }
func RunServer(addr string) { self := new(Server).Init() rpc.Register(self) rpc.HandleHTTP() l, e := net.Listen("tcp", addr) if e != nil { log.Exit("listen error: ", e) } http.Serve(l, nil) }
//Starts the server func main() { md := NewMatrixDatabase() rpc.Register(md) rpc.HandleHTTP() l, e := net.Listen("tcp", ":1234") if e != nil { log.Fatal("listen error:", e) } http.Serve(l, nil) }
func main() { flag.Parse() t := &LunchTracker{NewPoll()} rpc.Register(t) rpc.HandleHTTP() l, e := net.Listen("tcp", ":"+strconv.Uitoa(*port)) if e != nil { log.Exit("listen error:", e) } http.Serve(l, nil) }
func NewRpcService(sig interface{}) *RpcService { ////star_name := reflect.TypeOf(sig).String()) type_name := reflect.Indirect(reflect.ValueOf(sig)).Type().Name() rpc.Register(sig) r := &RpcService{ Port: *Port, IPAddress: *BindIP, Provides: type_name, Protocol: strings.ToLower(*Protocol), } return r }
func main() { flag.Parse() log.Printf("Server starting on port %d\n", *portnum) if *nodeID == 0 { rand.Seed(time.Nanoseconds()) *nodeID = uint(rand.Uint32()) } ss := storageserver.NewStorageserver(*storageMasterNodePort, *numNodes, *portnum, uint32(*nodeID)) ts := NewTribserver(ss) rpc.Register(ts) srpc := storagerpc.NewStorageRPC(ss) rpc.Register(srpc) rpc.HandleHTTP() l, e := net.Listen("tcp", fmt.Sprintf(":%d", *portnum)) if e != nil { log.Fatal("listen error:", e) } log.Printf("Establishing connection with storage servers") go ss.Connect(l.Addr()) http.Serve(l, nil) }
// Start this server. func (s *PBServer) run() error { logger.Info(fmt.Sprintf("Server %s is running...", s.addr)) // Start rpc server to dispatch client's request. if err := rpc.Register(s, s.addr); err != nil { return err } s.group.Run() // Start heart beat. go s.tick() return nil }
func main() { flag.Parse() httperf := new(HTTPerf) rpc.Register(httperf) rpc.HandleHTTP() l, e := net.Listen("tcp", fmt.Sprintf("%s:%d", *host, *port)) if e != nil { log.Fatalf("listen error:", e) } log.Printf("Now listening for requests on %s:%d", *host, *port) http.Serve(l, nil) }
func serve(configs *ConfigOpts) os.Error { ks := NewKeySpace(configs.ZkRootNode, configs.ZkHosts, 5e6) ks.Connect() rs := &SimpleRep{N: configs.ReplicationFactor} ls := NewDiskStore(configs.RootDir) rsf := &RemoteStoreFactory{} b := NewBlobStore(ks, rs, ls, rsf, configs.Port) rpc.Register(b) rpc.HandleHTTP() addr := fmt.Sprintf(":%d", configs.Port) l4g.Info("Serving on %s", addr) http.ListenAndServe(addr, nil) return nil }
func main() { sfs := new(SFS) status := new(Status) Init(status) rpc.Register(sfs) rpc.HandleHTTP() l, e := net.Listen("tcp", ":1234") if e != nil { log.Fatal("listen error:", e) } http.Serve(l, nil) fmt.Println("done") }
func main() { m := new(master.Master) flag.Parse() rpc.Register(m) l, _ := net.Listen("tcp", ":1338") /*if e != nil { log.Fatal("listen error:", e) }*/ rpc.Accept(l) fmt.Println("done") }
func serverFunc() int { socketfname := getSocketFilename() if fileExists(socketfname) { fmt.Printf("unix socket: '%s' already exists\n", socketfname) return 1 } daemon = NewAutoCompletionDaemon(socketfname) defer os.Remove(socketfname) rpcremote := new(RPCRemote) rpc.Register(rpcremote) daemon.acr.Loop() return 0 }
func main() { ta := &testApp{"fooname"} rpc.Register(ta) l, err := net.Listen("tcp", listenport) if err != nil { log.Exit("Listen error: ", err) } else { log.Println("Listening: ", l) } a := "foo" var c string ta.PrintStuff(&a, &c) log.Println(c) for conn, err := l.Accept(); err == nil; conn, err = l.Accept() { log.Println(conn) go rpc.ServeCodec(jsonrpc.NewServerCodec(conn)) } log.Exit("Error: ", err) }
func main() { masterAddress := flag.Arg(0) chunkServ := new(chunk.Server) chunk.Init(masterAddress) go chunk.SendHeartbeat(masterAddress) //go chunk.LogStats() rpc.Register(chunkServ) log.Println("chunk: Server Online.") l, e := net.Listen("tcp", ":1337") if e != nil { log.Fatal("chunk error:", e) } rpc.Accept(l) log.Println("chunk: done.") }
func newMaster(file string, mapper Mapper, reducer Reducer, nMapper, nReducer uint32) *Master { logger.Info("Creating master...") // Generate jobs informations. jobs := make(map[JobType]*jobInfo, 2) jobs[Map] = &jobInfo{ Number: nMapper, Executor: mapper, RJobs: dsync.NewSQueue(0, nMapper), } jobs[Reduce] = &jobInfo{ Number: nReducer, Executor: reducer, RJobs: dsync.NewSQueue(0, nReducer), } // Initial untreated job. for i := uint32(0); i < nMapper; i++ { jobs[Map].RJobs.Put(i) } for i := uint32(0); i < nReducer; i++ { jobs[Reduce].RJobs.Put(i) } m := &Master{ file: file, jobs: jobs, idleWorkers: NewworkerPool(), doneJobs: make(chan *rpc.Context, nMapper+nReducer), finished: 0, lock: sync.Mutex{}, done: make(chan bool), workers: make([]string, 0), } // Register as a rpc server. rpc.Register(m, masterAddress) logger.Info("Master is created") return m }
func main() { log.Print("Starting Server...") l, err := net.Listen("tcp", "localhost:1234") defer l.Close() if err != nil { log.Fatal(err) } log.Print("listening on: ", l.Addr()) rpc.Register(new(RPCFunc)) for { log.Print("waiting for connections ...") conn, err := l.Accept() if err != nil { log.Printf("accept error: %s", conn) continue } log.Printf("connection started: %v", conn.RemoteAddr()) go jsonrpc.ServeConn(conn) } }
func (w *Worker) run() { // Register as a rpc server rpc.Register(w, w.address) // Register as a worker for master. args := &RegisterArgs{ Worker: w.address, } reply := new(RegisterReply) err := rpc.Call(masterAddress, "Master.Register", args, reply) if err != nil { logger.Error(fmt.Sprintf("Cannot register %s as a worker", err)) rpc.Close(w) return } w.file = reply.File w.mapper = reply.CMapper w.reducer = reply.CReducer w.nMapper = reply.NumMapper w.nReducer = reply.NumReducer }
func serverFunc() int { readConfig(&Config) addr := *addr if *sock == "unix" { addr = getSocketFilename() if fileExists(addr) { fmt.Printf("unix socket: '%s' already exists\n", addr) return 1 } } daemon = NewDaemon(*sock, addr) if *sock == "unix" { // cleanup unix socket file defer os.Remove(addr) } rpcremote := new(RPCRemote) rpc.Register(rpcremote) daemon.acr.Loop() return 0 }
// The Router application registers RPC listeners to accept from the initiators // then registers RPC clients to each of the external services it may call. func main() { var err os.Error // Pull in command line options or defaults if none given flag.Parse() f, err := os.OpenFile(*skylib.LogFileName, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666) if err == nil { defer f.Close() log.SetOutput(f) } skylib.Setup(sName) CreateInitialRoute() route, err = skylib.GetRoute(sName) if err != nil { log.Panic("Unable to retrieve route.") } r := &RouteService{Name: *skylib.Name} rpc.Register(r) rpc.HandleHTTP() portString := fmt.Sprintf("%s:%d", *skylib.BindIP, *skylib.Port) l, e := net.Listen("tcp", portString) if e != nil { log.Fatal("listen error:", e) } log.Println("Starting server") http.Serve(l, nil) }
func main() { flag.Parse() masterAddress := flag.Arg(0) chunkServ := new(chunk.Server) if *logging { chunk.Init(masterAddress, true) } else { chunk.Init(masterAddress, false) } go chunk.SendHeartbeat(masterAddress) rpc.Register(chunkServ) log.Println("chunk: Server Online.") l, e := net.Listen("tcp", ":1337") if e != nil { log.Fatal("chunk error:", e) } rpc.Accept(l) log.Println("chunk: done.") }
func init() { rpc.Register(new(Arith)) }
// Start server. func (vs *ViewServer) run() { logger.Info("View server is running...") rpc.Register(vs, vs.addr) go vs.monitor() }
// Method to register the heartbeat of each skynet // client with the healthcheck exporter. func RegisterHeartbeat() { r := NewService("Service.Ping") rpc.Register(r) }
func main() { flag.Parse() if *logFile == "stderr" { log.SetOutput(os.Stderr) } else { logger, err := os.Open(*logFile, os.O_WRONLY|os.O_CREATE, 0640) if err != nil { log.SetOutput(os.Stderr) log.Exit(err) } log.SetOutput(logger) } if *displayHelp { flag.PrintDefaults() return } userMap = make(map[string]*Auth) err := loadUsersFromFile() if err != nil { log.Exit("Error reading config file. Have you created it?\nCaused By: ", err) } var t *LunchTracker if *dataFile != "" { stat, err := os.Stat(*dataFile) if err != nil { panic(err) } if stat.IsRegular() { file, ferr := os.Open(*dataFile, os.O_RDONLY, 0600) if ferr != nil { panic(ferr) } t = oldPollChan(file) } } else { t = newPollChan() } *dataFile = "poll.gob" rpc.Register(t) l, e := net.Listen("tcp", ":"+strconv.Uitoa(*port)) if e != nil { log.Exit("listen error:", e) } for { conn, err := l.Accept() if err != nil { log.Println("Failed to accept client", err) } else { go func() { defer func() { if x := recover(); x != nil { log.Println("Fatal Exception", x) } }() rpc.ServeConn(conn) }() } } }
func init() { rpc.Register(new(TimeService)) }