Exemple #1
0
func wrap(f interface{}) func(*cli.Context) {
	return func(ctx *cli.Context) {
		if ctx.GlobalBool("debug") {
			log.SetOutputLevel(log.Ldebug)
		}

		sockPath := filepath.Join(GOSUV_HOME, "gosuv.sock")
		if err := testConnection("unix", sockPath); err != nil {
			log.Fatal(err)
		}

		conn, err := connect(ctx)
		if err != nil {
			log.Fatal(err)
		}
		defer conn.Close()
		programClient := pb.NewProgramClient(conn)
		gosuvClient := pb.NewGoSuvClient(conn)

		inj := inject.New()
		inj.Map(programClient)
		inj.Map(gosuvClient)
		inj.Map(ctx)
		inj.Invoke(f)
	}
}
Exemple #2
0
func ShutdownAction(ctx *cli.Context) {
	conn, err := connect(ctx)
	if err != nil {
		fmt.Println("server already closed")
		return
	}
	defer conn.Close()

	client := pb.NewGoSuvClient(conn)
	res, err := client.Shutdown(context.Background(), &pb.NopRequest{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(res.Message)
}