monitorv2

package
v0.1.99 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MonitorV2Cmd = &cobra.Command{
	Use:   "monitorv2",
	Short: "Monitor v2 command stub.",
	Long:  usage,
	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {

		verbosityFlag := cmd.Flag("verbosity")
		if verbosityFlag != nil && !verbosityFlag.Changed {
			util.SetLogLevel(300)
		}
		return nil
	},
	RunE: func(cmd *cobra.Command, args []string) error {
		if rpcURL == "" {
			return fmt.Errorf("--rpc-url is required")
		}

		if pprofAddr != "" {
			go func() {
				log.Info().Str("addr", pprofAddr).Msg("Starting pprof server")
				if err := http.ListenAndServe(pprofAddr, nil); err != nil {
					log.Error().Err(err).Msg("pprof server failed")
				}
			}()
		}

		store, err := chainstore.NewPassthroughStore(rpcURL)
		if err != nil {
			return fmt.Errorf("failed to create store: %w", err)
		}
		defer store.Close()

		idx := indexer.NewIndexer(store, indexer.DefaultConfig())

		if err := idx.Start(); err != nil {
			return fmt.Errorf("failed to start indexer: %w", err)
		}
		defer func() {
			if err := idx.Stop(); err != nil {

				fmt.Fprintf(os.Stderr, "Warning: failed to stop indexer: %v\n", err)
			}
		}()

		// Create renderer based on type
		var r renderer.Renderer
		switch rendererType {
		case "json":
			r = renderer.NewJSONRenderer(idx)
		case "tview", "tui":
			r = renderer.NewTviewRenderer(idx)
		default:
			return fmt.Errorf("unknown renderer type: %s (supported: json, tview, tui)", rendererType)
		}

		ctx := context.Background()
		return r.Start(ctx)
	},
}

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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