Example #1
0
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)

	homeTmpl = template.MustParse(homeTemplate, nil)
	respTmpl = template.MustParse(responseTemplate, nil)

	http.HandleFunc("/", homeHandler)
	http.HandleFunc("/new", submitHandler)

	rpc.HandleHTTP()

	portString := fmt.Sprintf("%s:%d", *skylib.BindIP, *skylib.Port)

	err = http.ListenAndServe(portString, nil)
	if err != nil {
		log.Fatal("ListenAndServe: ", err.String())
	}
}
Example #2
0
func main( )
{
	rpc.HandleHTTP();

	l, _ := net.Listen("tcp", ":8089");
	http.Serve(l, http.HandlerFunc( handleRequest ) );
}
Example #3
0
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)

	homeTmpl = template.MustParse(homeTemplate, nil)
	respTmpl = template.MustParse(responseTemplate, nil)

	rpc.HandleHTTP()

	portString := fmt.Sprintf("%s:%d", *skylib.BindIP, *skylib.Port)

	stack := new(mango.Stack)
	stack.Address = portString

	routes := make(map[string]mango.App)
	routes["/"] = homeHandler
	routes["/new"] = submitHandler
	stack.Middleware(mango.Routing(routes))
	stack.Run(nil)
}
Example #4
0
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)

}
Example #5
0
// At the moment, this can start more than one Server on the same
// port, which could be a problem.
func (self *RpcService) Serve(done chan bool) {
	portString := fmt.Sprintf("%s:%d", self.IPAddress, self.Port)
	log.Println(portString)

	l, e := net.Listen("tcp", portString)
	if e != nil {
		log.Fatal("listen error:", e)
	}
	defer l.Close()

	switch self.Protocol {
	default:
		rpc.HandleHTTP() // Seems safe to call multiple times, but must
		// that precede net.Listen()?
		log.Println("Starting http server")
		http.Serve(l, nil)
	case "json":
		log.Println("Starting jsonrpc server")
		for {
			conn, err := l.Accept()
			if err != nil {
				panic(err.String())
			}
			jsonrpc.ServeConn(conn)
		}
	}
	done <- true // This may never occur.
}
Example #6
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("Watcher.Generic") // Change this to be more descriptive

	rpc.HandleHTTP()

	go monitorServices()

	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)

}
Example #7
0
func main() {
	flag.Parse()
	rpc.Register(server)
	rpc.HandleHTTP()
	http.HandleFunc("/", Static)
	http.HandleFunc("/get", Get)
	http.ListenAndServe(*listenAddr, nil)
}
Example #8
0
// rpc over HTTP
func serveHTTP(addr string) {
	rpc.HandleHTTP()

	l, err := net.Listen("tcp", addr)
	if err != nil {
		log.Fatal(err)
	}
	http.Serve(l, nil)
}
Example #9
0
func main() {
	reg := NewReg()
	rpc.RegisterName(registry.Name, reg)
	rpc.HandleHTTP()
	l, e := net.Listen("tcp", ":"+strconv.Itoa(registry.Port))
	if e != nil {
		log.Fatal("listen error:", e)
	}
	http.Serve(l, nil)
}
Example #10
0
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)
}
Example #12
0
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)
}
Example #13
0
//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)
}
Example #14
0
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)
}
Example #15
0
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")
}
Example #16
0
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)
}
Example #17
0
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
}
Example #18
0
File: main.go Project: rsec/goto
func main() {
	flag.Parse()
	if *masterAddr != "" {
		store = NewProxyStore(*masterAddr)
	} else {
		store = NewURLStore(*dataFile)
	}
	if *rpcEnabled {
		rpc.RegisterName("Store", store)
		rpc.HandleHTTP()
	}
	http.HandleFunc("/", Redirect)
	http.HandleFunc("/add", Add)
	http.ListenAndServe(*listenAddr, nil)

}
Example #19
0
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)
}
Example #20
0
func Run(r Reducer, m Mapper) {
	flag.Parse()

	if *isMapper {
		if *reducerAddr == "" {
			flag.Usage()
			os.Exit(2)
		}
		log.Println("Acting as a Mapper")
		runMapper(*reducerAddr, m)
		return
	}

	log.Println("Acting as Reducer")
	rpc.RegisterName("Reducer", newReducer(r))
	rpc.HandleHTTP()
	err := http.ListenAndServe(*httpAddr, nil)
	if err != nil {
		log.Fatal(err)
	}
}
func initCentralTest(server, myhostport string) (*centralTester, error) {
	tester := new(centralTester)
	tester.myHostPort = myhostport
	// tester.recvRevoke = make(map[string]bool)
	// tester.compRevoke = make(map[string]bool)

	// Create RPC connection to storage server.
	srv, err := rpc.DialHTTP("tcp", server)
	if err != nil {
		return nil, fmt.Errorf("could not connect to server %s", server)
	}

	rpc.RegisterName("PearServer", serverrpc.Wrap(tester))
	rpc.HandleHTTP()

	l, err := net.Listen("tcp", fmt.Sprintf(":%d", *portnum))
	if err != nil {
		LOGE.Fatalln("Failed to listen:", err)
	}
	go http.Serve(l, nil)
	tester.srv = srv
	return tester, nil
}
Example #22
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)

}