run

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0, MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	APICmd = &cli.Command{
		Name:  "api",
		Usage: "Run the singularity API",
		Flags: []cli.Flag{
			&cli.StringFlag{
				Name:  "bind",
				Usage: "Bind address for the API server",
				Value: "127.0.0.1:9090",
			},
		},
		Action: api.Run,
	}
)
View Source
var ContentProviderCmd = &cli.Command{
	Name:  "content-provider",
	Usage: "Start a content provider that serves retrieval requests",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Category: "HTTP Retrieval",
			Name:     "http-bind",
			Usage:    "Address to bind the HTTP server to",
			Value:    "127.0.0.1:7777",
		},
		&cli.BoolFlag{
			Category: "HTTP Retrieval",
			Name:     "enable-http",
			Usage:    "Enable HTTP retrieval",
			Value:    true,
		},
		&cli.BoolFlag{
			Category: "Bitswap Retrieval",
			Name:     "enable-bitswap",
			Usage:    "Enable bitswap retrieval",
			Value:    false,
		},
		&cli.StringFlag{
			Category:    "Bitswap Retrieval",
			Name:        "libp2p-identity-key",
			Usage:       "The base64 encoded private key for libp2p peer",
			Value:       "",
			DefaultText: "AutoGenerated",
		},
		&cli.StringSliceFlag{
			Category: "Bitswap Retrieval",
			Name:     "libp2p-listen",
			Usage:    "Addresses to listen on for libp2p connections",
		},
	},
	Action: func(c *cli.Context) error {
		db := database.MustOpenFromCLI(c)
		err := model.AutoMigrate(db)
		if err != nil {
			return handler.NewHandlerError(err)
		}

		config := service.ContentProviderConfig{
			EnableHTTP:        c.Bool("enable-http"),
			HTTPBind:          c.String("http-bind"),
			EnableBitswap:     c.Bool("enable-bitswap"),
			Libp2pIdentityKey: c.String("libp2p-identity-key"),
			Libp2pListenAddrs: c.StringSlice("libp2p-listen"),
		}

		s, err := service.NewContentProviderService(db, config)
		if err != nil {
			return cli.Exit(err.Error(), 1)
		}
		s.Start(c.Context)
		return nil
	},
}
View Source
var DatasetWorkerCmd = &cli.Command{
	Name:  "dataset-worker",
	Usage: "Start a dataset preparation worker to process dataset scanning and preparation tasks",
	Flags: []cli.Flag{
		&cli.IntFlag{
			Name:    "concurrency",
			Usage:   "Number of concurrent workers to run",
			EnvVars: []string{"DATASET_WORKER_CONCURRENCY"},
			Value:   1,
		},
		&cli.BoolFlag{
			Name:    "enable-scan",
			Usage:   "Enable scanning of datasets",
			EnvVars: []string{"DATASET_WORKER_ENABLE_SCAN"},
			Value:   true,
		},
		&cli.BoolFlag{
			Name:    "enable-pack",
			Usage:   "Enable packing of datasets that calculates CIDs and packs them into CAR files",
			EnvVars: []string{"DATASET_WORKER_ENABLE_PACK"},
			Value:   true,
		},
		&cli.BoolFlag{
			Name:    "enable-dag",
			Usage:   "Enable dag generation of datasets that maintains the directory structure of datasets",
			EnvVars: []string{"DATASET_WORKER_ENABLE_DAG"},
			Value:   true,
		},
		&cli.BoolFlag{
			Name:    "exit-on-complete",
			Usage:   "Exit the worker when there is no more work to do",
			EnvVars: []string{"DATASET_WORKER_EXIT_ON_COMPLETE"},
			Value:   false,
		},
		&cli.BoolFlag{
			Name:    "exit-on-error",
			Usage:   "Exit the worker when there is any error",
			EnvVars: []string{"DATASET_WORKER_EXIT_ON_ERROR"},
			Value:   false,
		},
	},
	Action: func(c *cli.Context) error {
		db := database.MustOpenFromCLI(c)
		err := model.AutoMigrate(db)
		if err != nil {
			return handler.NewHandlerError(err)
		}
		worker := datasetworker.NewDatasetWorker(
			db,
			datasetworker.DatasetWorkerConfig{
				Concurrency:    c.Int("concurrency"),
				EnableScan:     c.Bool("enable-scan"),
				EnablePack:     c.Bool("enable-pack"),
				EnableDag:      c.Bool("enable-dag"),
				ExitOnComplete: c.Bool("exit-on-complete"),
				ExitOnError:    c.Bool("exit-on-error"),
			})
		err = worker.Run(c.Context)
		if err != nil {
			return err
		}
		return nil
	},
}
View Source
var DealMakerCmd = &cli.Command{
	Name:  "dealmaker",
	Usage: "Start a deal making/tracking worker to process deal making",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:     "lotus-api",
			Category: "Lotus",
			Usage:    "Lotus RPC API endpoint, only used to get miner info",
			Value:    "https://api.node.glif.io/rpc/v1",
		},
		&cli.StringFlag{
			Name:     "lotus-token",
			Category: "Lotus",
			Usage:    "Lotus RPC API token, only used to get miner info",
			Value:    "",
		},
	},
	Action: func(c *cli.Context) error {
		db := database.MustOpenFromCLI(c)
		err := model.AutoMigrate(db)
		if err != nil {
			return handler.NewHandlerError(err)
		}
		dealMaker, err := service.NewDealMakerService(db, c.String("lotus-api"), c.String("lotus-token"))
		if err != nil {
			return cli.Exit(err.Error(), 1)
		}
		return dealMaker.Run(c.Context)
	},
}
View Source
var SpadeAPICmd = &cli.Command{
	Name:  "spade-api",
	Usage: "Start a Spade compatible API for storage provider deal proposal self service",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:  "bind",
			Usage: "Bind address for the API server",
			Value: "127.0.0.1:9091",
		},
		&cli.StringFlag{
			Name:     "lotus-api",
			Category: "Lotus",
			Usage:    "Lotus RPC API endpoint, only used to get miner info",
			Value:    "https://api.node.glif.io/rpc/v1",
		},
		&cli.StringFlag{
			Name:     "lotus-token",
			Category: "Lotus",
			Usage:    "Lotus RPC API token, only used to get miner info",
			Value:    "",
		},
	},
	Action: func(c *cli.Context) error {
		db := database.MustOpenFromCLI(c)
		err := model.AutoMigrate(db)
		if err != nil {
			return handler.NewHandlerError(err)
		}

		h, err := util.InitHost(context.Background(), nil)
		if err != nil {
			return err
		}

		dealMaker, err := replication.NewDealMaker(c.String("lotus-api"), c.String("lotus-token"), h)
		if err != nil {
			return err
		}

		return service.NewSpadeAPIService(db, dealMaker, &replication.WalletChooser{}, c.String("bind")).Start()
	},
}

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