示例#1
0
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())

	f := flag.String("fakeways", "192.168.55.1,192.168.66.1", "Default gateways expected by hosts")
	name := flag.String("name", "", "netapp name, supported: l2-forwarder, l3-forwarder")
	listen := flag.String("listen", ":6633", "controller's ip:port to listen")
	apiOn := flag.String("apiOn", "", "bind addr:port to serve API, e.g. :8080")
	flag.Parse()

	fakeways := strings.Split(*f, ",")

	ctrl := ogo.NewController()

	switch *name {
	case "l2-forwarder":
		ctrl.RegisterApplication(netapps.NewL2Forwarder)
	case "l3-forwarder":
		ctrl.RegisterApplication(netapps.NewL3Forwarder(fakeways))
	case "demo":
		ctrl.RegisterApplication(netapps.NewDemoInstance)
	default:
		log.Println("No netapps selected, controller will be run in core mode")
	}

	if *apiOn != "" {
		go netapps.NewWebService(*apiOn)
	}

	ctrl.Listen(*listen)
}
示例#2
0
文件: application.go 项目: 3d0c/ogo
func main() {
	fmt.Println("Ogo 2013")
	runtime.GOMAXPROCS(runtime.NumCPU())
	ctrl := ogo.NewController()
	hostMap = *NewHostMap()
	ctrl.RegisterApplication(NewDemoInstance)
	ctrl.Listen(":6633")
}