Exemple #1
0
func NewFakeFusisServer() *FakeFusisServer {
	balancer := newTestBalancer()
	apiHandler := api.NewAPI(balancer)
	srv := httptest.NewServer(apiHandler)
	return &FakeFusisServer{
		Server:   srv,
		api:      &apiHandler,
		Balancer: balancer,
	}
}
Exemple #2
0
func balancerCommandFunc(cmd *cobra.Command, args []string) {
	if err := net.SetIpForwarding(); err != nil {
		log.Warn("Fusis couldn't set ip forwarding in the kernel with net.ipv4.ip_forward=1")
		log.Fatal(err)
	}

	if err := conf.Validate(); err != nil {
		log.Fatal("Invalid configuration file: ", err)
		os.Exit(1)
	}

	balancer, err := fusis.NewBalancer(&conf)
	if err != nil {
		log.Fatal(err)
	}

	apiService := api.NewAPI(balancer)
	go apiService.Serve()

	waitSignals(balancer)
}