예제 #1
0
파일: main.go 프로젝트: tcolgate/radia
func newVISGHSExecutor() *ghsvisExecutor {
	log.Infoln("Initializing the VISGHS Executor...", *tracerAddr)
	c, err := tracer.NewGRPCDisplayClient(*tracerAddr, grpc.WithInsecure())
	if err != nil {
		log.Fatalf("failed to connect: %v", err)
	}
	t := tracer.New(c)

	// Establish gRPC on the deisgnated port
	lis, err := net.Listen("tcp", ":0")
	if err != nil {
		log.Fatalf("grpc failed to listen: %v", err)
	}
	grpcServer := grpc.NewServer()

	// build command executor
	nexec := prepareExecutorInfo(lis.Addr())
	s := newvisghsScheduler(nexec)

	t := tracer.NewHTTPDisplay(http.DefaultServeMux, s.OnRun)
	server := tracer.NewGRPCServer(t)
	tracer.RegisterTraceServiceServer(grpcServer, server)
	go grpcServer.Serve(lis)
	time.Sleep(2 * time.Second)
	go http.ListenAndServe(":12345", nil)

	return &ghsvisExecutor{tasksLaunched: 0, Tracer: t}
}
예제 #2
0
파일: main.go 프로젝트: tcolgate/radia
func main() {
	if *ghsNode {
		ghsNodeMain()
		return
	}

	// Allocate a port for GRPC
	lis, err := net.Listen("tcp", ":0")
	if err != nil {
		log.Fatalf("grpc failed to listen: %v", err)
	}
	grpcServer := grpc.NewServer()

	// build command executor
	nexec := prepareExecutorInfo(lis.Addr())
	s := newvisghsScheduler(nexec)

	t := tracer.NewHTTPDisplay(http.DefaultServeMux, s.OnRun)
	server := tracer.NewGRPCServer(t)
	tracer.RegisterTraceServiceServer(grpcServer, server)
	go grpcServer.Serve(lis)
	time.Sleep(2 * time.Second)
	go http.ListenAndServe(":12345", nil)

	// the framework
	fwinfo := &mesos.FrameworkInfo{
		User: proto.String(""), // Mesos-go will fill in user.
		Name: proto.String("visghs"),
	}

	cred := (*mesos.Credential)(nil)
	if *mesosAuthPrincipal != "" {
		fwinfo.Principal = proto.String(*mesosAuthPrincipal)
		cred = &mesos.Credential{
			Principal: proto.String(*mesosAuthPrincipal),
		}
		if *mesosAuthSecretFile != "" {
			_, err := os.Stat(*mesosAuthSecretFile)
			if err != nil {
				log.Fatal("missing secret file: ", err.Error())
			}
			secret, err := ioutil.ReadFile(*mesosAuthSecretFile)
			if err != nil {
				log.Fatal("failed to read secret file: ", err.Error())
			}
			cred.Secret = proto.String(string(secret))
		}
	}

	bindingAddress := parseIP(*address)
	config := sched.DriverConfig{
		Scheduler:      s,
		Framework:      fwinfo,
		Master:         *master,
		Credential:     cred,
		BindingAddress: bindingAddress,
		WithAuthContext: func(ctx context.Context) context.Context {
			ctx = auth.WithLoginProvider(ctx, *authProvider)
			ctx = sasl.WithBindingAddress(ctx, bindingAddress)
			return ctx
		},
	}
	driver, err := sched.NewMesosSchedulerDriver(config)

	if err != nil {
		log.Errorln("Unable to create a SchedulerDriver ", err.Error())
	}

	if stat, err := driver.Run(); err != nil {
		log.Infof("Framework stopped with status %s and error: %s\n", stat.String(), err.Error())
		time.Sleep(2 * time.Second)
		os.Exit(1)
	}
	log.Infof("framework terminating")
}