Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RootCmd = &cobra.Command{ Use: "edward", Short: "A tool for managing local instances of microservices", Long: `Edward is a tool to simplify your microservices development workflow. Build, start and manage service instances with a single command.`, SilenceUsage: true, PersistentPreRunE: func(cmd *cobra.Command, args []string) error { var dirConfig *home.EdwardConfiguration var err error dirConfig = &home.EdwardConfiguration{} if edwardHome != "" { err = dirConfig.InitializeWithDir(edwardHome) } else { err = dirConfig.Initialize() } if err != nil { return errors.WithStack(err) } if redirectLogs { logger = log.New(os.Stdout, fmt.Sprintf("%v >", os.Args), log.Ldate|log.Ltime|log.Lmicroseconds|log.Lshortfile) } prefix := "edward" if len(args) > 0 { prefix = fmt.Sprintf("%s %s", cmd.Use, args[0]) } logger = log.New(&lumberjack.Logger{ Filename: path.Join(dirConfig.EdwardLogDir, "edward.log"), MaxSize: 50, MaxBackups: 30, MaxAge: 1, }, fmt.Sprintf("%s > ", prefix), log.Ldate|log.Ltime|log.Lmicroseconds|log.Lshortfile) logger.Printf("=== Edward v%v ===\n", common.EdwardVersion) logger.Printf("Args: %v\n", os.Args) defer func() { if r := recover(); r != nil { fmt.Println("Recovered from panic:", r) if logger != nil { logger.Printf("Recovered from panic: %v", r) } } if logger != nil { logger.Printf("=== Exiting ===\n") } }() if configPath == "" { var err error tmpDirCfg := &home.EdwardConfiguration{} err = tmpDirCfg.Initialize() if err != nil { return errors.WithStack(err) } configPath, err = config.GetConfigPathFromWorkingDirectory(tmpDirCfg.Dir) if err != nil { return errors.WithStack(err) } } command := cmd.Use if command != "generate" { edwardClient, err = edward.NewClientWithConfig(configPath, common.EdwardVersion, logger) if err != nil { return errors.WithStack(err) } err = os.Chdir(edwardClient.BasePath()) if err != nil { return errors.WithStack(err) } } else { edwardClient, err = edward.NewClient() if err != nil { return errors.WithStack(err) } } edwardClient.DirConfig = dirConfig edwardClient.ServiceChecks = func(sgs []services.ServiceOrGroup) error { return errors.WithStack(sudoIfNeeded(sgs)) } edwardClient.Logger = logger edwardClient.EdwardExecutable = os.Args[0] edwardClient.LogFile = logFile if redirectLogs { edwardClient.Follower = output.NewNonLiveFollower() } if command != "stop" { for _, service := range edwardClient.ServiceMap() { if _, err := os.Stat(service.GetPidPathLegacy(edwardClient.DirConfig.PidDir)); !os.IsNotExist(err) { return errors.New("one or more services were started with an older version of Edward. Please run `edward stop` to stop these instances") } } } if command != "run" { checkUpdateChan = make(chan interface{}) go checkUpdateAvailable(edwardClient.DirConfig.Dir, checkUpdateChan) } return nil }, PersistentPostRun: func(cmd *cobra.Command, args []string) { if checkUpdateChan != nil { updateAvailable, ok := (<-checkUpdateChan).(bool) if ok && updateAvailable { latestVersion := (<-checkUpdateChan).(string) fmt.Printf("A new version of Edward is available (%v), update with:\n\tgo get -u github.com/yext/edward\n", latestVersion) } } }, }
RootCmd represents the base command when called without any subcommands
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.