startcmd

package
v0.0.32 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AttachCmd = &cobra.Command{
	Use:   "attach",
	Short: "Start a JavaScript console attached to a node",
	Run: func(cmd *cobra.Command, args []string) {
		viper.Set("attachmode", true)
		execCode, _ := cmd.Flags().GetString("exec")

		rpcClient, _, err := connectToServer(cfg)
		if err != nil {
			log.Fatal(errors.Wrapf(err, "failed to connect to RPC server @ %s", cfg.Remote.Address).Error())
		}

		console := console.New(cfg)
		ks := keystore.New(cfg.KeystoreDir())
		console.SetModulesHub(modules.NewAttachable(cfg, rpcClient, ks))
		console.OnStop(func() {
			config.GetInterrupt().Close()
		})

		go func() {
			if err := console.Run(execCode); err != nil {
				log.Fatal(err.Error())
			}
		}()

		config.GetInterrupt().Wait()
	},
}

AttachCmd represents the attach command

View Source
var ConsoleCmd = &cobra.Command{
	Use:   "console",
	Short: "Start a JavaScript console and connect the node to the network",
	Run: func(cmd *cobra.Command, args []string) {
		listenForInterrupt()

		start(func(n *node.Node) {
			console := console.New(cfg)

			console.OnStop(func() {
				n.Stop()
			})

			console.SetModulesHub(n.GetModulesHub())

			go func() {
				if err := console.Run(); err != nil {
					log.Fatal(err.Error())
				}
			}()
		})
	},
}

ConsoleCmd represents the console command

View Source
var StartCmd = &cobra.Command{
	Use:   "start",
	Short: "Launch the node to join the network.",
	Run: func(cmd *cobra.Command, args []string) {
		listenForInterrupt()
		start(nil)
	},
}

StartCmd represents the start command

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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