Help us shape the future of Go! Take the 2026 Go Developer Survey

commands

package
v1.3.102 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

Package commands cmd/svc/setup-node/commands/root.go c2-net-routing

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use: func() string {
		return strings.Split(filepath.Base(strings.ReplaceAll(strings.ReplaceAll(fmt.Sprintf("%v", os.Args), "[", ""), "]", ""))+" [config.json]", " ")[0]
	}(),
	Short: "Route Setup Node for skywire",
	Long: calvin.AsciiFont("route-setup-node") + `
Route Setup Node - establishes routes between visors via dmsg RPC.

Listens on dmsg port ` + fmt.Sprintf("%d", skyenv.DmsgSetupPort) + ` for route setup requests from visors.

RPC Methods (via dmsg):
  SetupRPCGateway.DialRouteGroup    Establish bidirectional route
  SetupRPCGateway.HealthCheck       Health check
` + generateExamples() + `

Usage:
  skywire svc sn [config.json]
  skywire cli config gen --sn -o sn-config.json
  skywire cli config gen --sn | skywire svc sn -i`,
	Run: func(_ *cobra.Command, args []string) {
		mLog := logging.NewMasterLogger()
		logger := logging.MustGetLogger(tag)

		if _, err := buildinfo.Get().WriteTo(mLog.Out); err != nil {
			mLog.Printf("Failed to output build info: %v", err)
		}

		var rdr io.Reader
		if !cfgFromStdin {
			configFile := "config.json"
			if len(args) > 0 {
				configFile = args[0]
			}
			f, err := os.Open(configFile)
			if err != nil {
				logger.Fatalf("Failed to open config: %v", err)
			}
			rdr = f
		} else {
			logger.Info("Reading config from STDIN")
			rdr = bufio.NewReader(cmdutil.Stdin())
		}
		raw, err := io.ReadAll(rdr)
		if err != nil {
			logger.Fatalf("Failed to read config: %v", err)
		}
		var setupConf router.SetupConfig
		if err := json.Unmarshal(raw, &setupConf); err != nil {
			logger.WithField("raw", string(raw)).Fatalf("Failed to decode config: %s", err)
		}

		cfg := &sn.Config{
			SetupConfig: setupConf,
			MetricsAddr: metricsAddr,
			PProfMode:   pprofMode,
			PProfAddr:   pprofAddr,
			Tag:         tag,
		}

		ctx, cancel := cmdutil.SignalContext(context.Background(), logger)
		defer cancel()
		if err := sn.New(cfg, logger).Run(ctx); err != nil {
			logger.WithError(err).Fatal("setup-node: run failed")
		}
	},
}

RootCmd is the root command for setup node

Functions

func Execute

func Execute()

Execute executes root CLI command.

Types

This section is empty.

Jump to

Keyboard shortcuts

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