server

package
v0.0.0-...-fa720cf Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:   "server",
	Short: "Run the server",
	Args:  cobra.NoArgs,
	PreRunE: func(cmd *cobra.Command, args []string) error {
		dconf := config.DefaultConfig()
		if configFile != "" {
			err := config.ParseConfigFile(configFile, dconf)
			if err != nil {
				return fmt.Errorf("error processing config file: %v", err)
			}
			dconf.SetDefaults()
		} else {
			if driver == "badger" {
				dconf.AddBadgerDefault()
			} else if driver == "pebble" {
				dconf.AddPebbleDefault()
			} else if driver == "mongo" {
				dconf.AddMongoDefault()
			}
		}
		if pluginDir != "" {
			dconf.Server.EnablePlugins = true
			dconf.Server.PluginDir = pluginDir
		}

		err := mergo.MergeWithOverwrite(dconf, conf)
		if err != nil {
			return fmt.Errorf("error processing config file: %v", err)
		}
		conf = dconf

		defaults := config.DefaultConfig()
		if conf.Server.RPCAddress() != defaults.Server.RPCAddress() {
			if conf.Server.RPCAddress() != conf.RPCClient.ServerAddress {
				conf.RPCClient.ServerAddress = conf.Server.RPCAddress()
			}
		}
		return nil
	},
	RunE: func(cmd *cobra.Command, args []string) error {
		return Run(conf, configFile)
	},
}

Cmd the main command called by the cobra library

Functions

func Run

func Run(conf *config.Config, baseDir string) error

Run runs an Grip server. This opens a database and starts an API server. This blocks indefinitely.

Types

This section is empty.

Jump to

Keyboard shortcuts

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