func main() { flag.Parse() ctx, cancel := context.WithTimeout(context.Background(), *actionTimeout) defer cancel() sigChan := make(chan os.Signal, 1) signal.Notify(sigChan, syscall.SIGTERM, syscall.SIGINT) go func() { s := <-sigChan log.Errorf("Trying to cancel current command after receiving signal: %v", s) cancel() }() logger := logutil.NewConsoleLogger() err := vtworkerclient.RunCommandAndWait( ctx, *server, flag.Args(), func(e *logutilpb.Event) { logutil.LogEvent(logger, e) }) if err != nil { log.Error(err) os.Exit(1) } }
func commandRestoreFromBackup(ctx context.Context, wr *wrangler.Wrangler, subFlags *flag.FlagSet, args []string) error { if err := subFlags.Parse(args); err != nil { return err } if subFlags.NArg() != 1 { return fmt.Errorf("The RestoreFromBackup command requires the <tablet alias> argument.") } tabletAlias, err := topoproto.ParseTabletAlias(subFlags.Arg(0)) if err != nil { return err } tabletInfo, err := wr.TopoServer().GetTablet(ctx, tabletAlias) if err != nil { return err } stream, err := wr.TabletManagerClient().RestoreFromBackup(ctx, tabletInfo.Tablet) if err != nil { return err } for { e, err := stream.Recv() switch err { case nil: logutil.LogEvent(wr.Logger(), e) case io.EOF: return nil default: return err } } }
func main() { flag.Parse() ctx, cancel := context.WithTimeout(context.Background(), *actionTimeout) defer cancel() logger := logutil.NewConsoleLogger() err := vtworkerclient.RunCommandAndWait( ctx, *server, flag.Args(), func(e *logutilpb.Event) { logutil.LogEvent(logger, e) }) if err != nil { log.Error(err) os.Exit(1) } }
func main() { defer exit.Recover() flag.Parse() logger := logutil.NewConsoleLogger() err := vtctlclient.RunCommandAndWait( context.Background(), *server, flag.Args(), *dialTimeout, *actionTimeout, func(e *logutilpb.Event) { logutil.LogEvent(logger, e) }) if err != nil { log.Error(err) os.Exit(1) } }