run

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: Apache-2.0, MIT Imports: 11 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, closer, err := database.OpenFromCLI(c)
		if err != nil {
			return err
		}
		defer closer.Close()
		if err := model.AutoMigrate(db); err != nil {
			return err
		}

		config := contentprovider.Config{
			HTTP: contentprovider.HTTPConfig{
				Enable: c.Bool("enable-http"),
				Bind:   c.String("http-bind"),
			},
			Bitswap: contentprovider.BitswapConfig{
				Enable:           c.Bool("enable-bitswap"),
				IdentityKey:      c.String("libp2p-identity-key"),
				ListenMultiAddrs: c.StringSlice("libp2p-listen"),
			},
		}

		s, err := contentprovider.NewService(db, config)
		if err != nil {
			return cli.Exit(err.Error(), 1)
		}
		return s.Start(c.Context)
	},
}
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, closer, err := database.OpenFromCLI(c)
		if err != nil {
			return err
		}
		defer closer.Close()
		if err := model.AutoMigrate(db); err != nil {
			return err
		}
		worker := datasetworker.NewWorker(
			db,
			datasetworker.Config{
				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 DealPusherCmd = &cli.Command{
	Name:  "deal-pusher",
	Usage: "Start a deal pusher that monitors deal schedules and pushes deals to storage providers",
	Flags: []cli.Flag{
		&cli.UintFlag{
			Name:    "deal-attempts",
			Usage:   "Number of times to attempt a deal before giving up",
			Aliases: []string{"d"},
			Value:   3,
		},
	},
	Action: func(c *cli.Context) error {
		db, closer, err := database.OpenFromCLI(c)
		if err != nil {
			return err
		}
		defer closer.Close()
		if err := model.AutoMigrate(db); err != nil {
			return err
		}

		lotusAPI := c.String("lotus-api")
		lotusToken := c.String("lotus-token")
		err = epochutil.Initialize(c.Context, lotusAPI, lotusToken)
		if err != nil {
			return err
		}

		dm, err := dealpusher.NewDealPusher(db, c.String("lotus-api"), c.String("lotus-token"), c.Uint("deal-attempts"))
		if err != nil {
			return cli.Exit(err.Error(), 1)
		}
		return service.StartServers(c.Context, dealpusher.Logger, dm)
	},
}
View Source
var DealTrackerCmd = &cli.Command{
	Name:  "deal-tracker",
	Usage: "Start a deal tracker that tracks the deal for all relevant wallets",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:    "market-deal-url",
			Usage:   "The URL for ZST compressed state market deals json. Set to empty to use Lotus API.",
			Aliases: []string{"m"},
			EnvVars: []string{"MARKET_DEAL_URL"},
			Value:   "https://marketdeals.s3.amazonaws.com/StateMarketDeals.json.zst",
		},
		&cli.DurationFlag{
			Name:    "interval",
			Usage:   "How often to check for new deals",
			Aliases: []string{"i"},
			Value:   1 * time.Hour,
		},
		&cli.BoolFlag{
			Name:  "once",
			Usage: "Run once and exit",
			Value: false,
		},
	},
	Action: func(c *cli.Context) error {
		db, closer, err := database.OpenFromCLI(c)
		if err != nil {
			return err
		}
		defer closer.Close()
		if err := model.AutoMigrate(db); err != nil {
			return err
		}

		lotusAPI := c.String("lotus-api")
		lotusToken := c.String("lotus-token")
		err = epochutil.Initialize(c.Context, lotusAPI, lotusToken)
		if err != nil {
			return err
		}

		tracker := dealtracker.NewDealTracker(db,
			c.Duration("interval"),
			c.String("market-deal-url"),
			c.String("lotus-api"),
			c.String("lotus-token"),
			c.Bool("once"),
		)

		return service.StartServers(c.Context, dealtracker.Logger, &tracker)
	},
}

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