cmd

package
v0.0.0-...-07a5fb3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TraceCmd = &cobra.Command{
	Use:   "trace",
	Short: "Perform a traceroute to a given host",

	RunE: func(cmd *cobra.Command, args []string) error {
		logger, err := getLogger()
		if err != nil {
			return err
		}

		_, cancel := context.WithCancel(context.Background())
		defer cancel()
		go listenExitCommand(logger, cancel)

		if len(args) < 1 {
			return errors.New(fmt.Sprintf("%s command requires 1 argument: host", cmd.Name()))
		}
		logger.Infof("Starting traceroute for host %s ...", args[0])
		options := &traceroute.TracerouteOptions{}
		options.SetRetries(traceParams.Probes - 1)
		options.SetMaxHops(traceParams.MaxHops + 1)
		options.SetFirstHop(traceParams.FirstHop)

		tracer, err := trace.NewTraceFromHost(args[0], options)
		if err != nil {
			return errors.Wrap(err, "error setting up traceroute")
		}
		err = tracer.Run()
		if err != nil {
			return errors.Wrap(err, "error getting traceroute")
		}

		logger.Infof("Node trace:\n%s", tracer.String())

		return nil
	},
}
View Source
var WatchCmd = &cobra.Command{
	Use:   "monitor",
	Short: "Monitor BCHD instances to be running at most recent block height",
	Long:  `This command will connect to BCHD instances via gRPC and ensure they are running properly.`,

	RunE: func(cmd *cobra.Command, args []string) error {
		logger, err := getLogger()
		if err != nil {
			return err
		}

		ctx, cancel := context.WithCancel(context.Background())
		defer cancel()
		go listenExitCommand(logger, cancel)
		monitor := createMonitoringClient(ctx, logger)

		// start all main workers in separate goroutines
		var wg sync.WaitGroup

		if monitor != nil {
			wg.Add(1)
			go func() {
				defer wg.Done()
				monitor.ListenHttp(ctx)
			}()
		}

		wg.Add(1)
		go func() {
			defer wg.Done()
			watchBchdNodes(ctx, logger, monitor)
		}()

		wg.Wait()
		return nil
	},
}

Functions

func Execute

func Execute()

Execute root command

Types

type TraceParams

type TraceParams struct {
	MaxHops  int
	FirstHop int
	Probes   int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL