From abbf4b84d6aedf67089071923475aa4fddbba1b1 Mon Sep 17 00:00:00 2001 From: Greg Linton Date: Wed, 18 Oct 2017 16:41:03 -0600 Subject: [PATCH] Enhance command output Fix a panic on linux if nfs server isn't running. Resolves #600 --- commands/dns/add.go | 7 ++++++- commands/dns/list.go | 7 ++++++- commands/dns/remove.go | 7 ++++++- commands/dns/remove_all.go | 7 ++++++- commands/info.go | 7 ++++++- commands/login.go | 6 +++--- commands/server/server.go | 2 +- processors/configure_set.go | 13 ++++++++++++- processors/provider/bridge/setup.go | 2 +- processors/run.go | 1 + util/provider/dockermachine.go | 16 ++++++++++++---- 11 files changed, 60 insertions(+), 15 deletions(-) diff --git a/commands/dns/add.go b/commands/dns/add.go index 71de2164..20ed71e6 100644 --- a/commands/dns/add.go +++ b/commands/dns/add.go @@ -38,6 +38,11 @@ func addFn(ccmd *cobra.Command, args []string) { app.Generate(env, name) display.CommandErr(app_dns.Add(env, app, args[0])) case "production": - fmt.Println("not yet implemented") + fmt.Printf(` +-------------------------------------------------------- +Production dns aliasing is not yet implemented. +-------------------------------------------------------- + +`) } } diff --git a/commands/dns/list.go b/commands/dns/list.go index ba29f1af..f03ad4df 100644 --- a/commands/dns/list.go +++ b/commands/dns/list.go @@ -33,6 +33,11 @@ func listFn(ccmd *cobra.Command, args []string) { app, _ := models.FindAppBySlug(config.EnvID(), name) display.CommandErr(app_dns.List(app)) case "production": - fmt.Println("not yet implemented") + fmt.Printf(` +-------------------------------------------------------- +Production dns aliasing is not yet implemented. +-------------------------------------------------------- + +`) } } diff --git a/commands/dns/remove.go b/commands/dns/remove.go index 5cbf6ab8..bd303199 100644 --- a/commands/dns/remove.go +++ b/commands/dns/remove.go @@ -36,6 +36,11 @@ func removeFn(ccmd *cobra.Command, args []string) { app, _ := models.FindAppBySlug(config.EnvID(), name) display.CommandErr(app_dns.Remove(app, args[0])) case "production": - fmt.Println("not yet implemented") + fmt.Printf(` +-------------------------------------------------------- +Production dns aliasing is not yet implemented. +-------------------------------------------------------- + +`) } } diff --git a/commands/dns/remove_all.go b/commands/dns/remove_all.go index ffd38216..5e536b5d 100644 --- a/commands/dns/remove_all.go +++ b/commands/dns/remove_all.go @@ -32,6 +32,11 @@ func removeAllFn(ccmd *cobra.Command, args []string) { app, _ := models.FindAppBySlug(config.EnvID(), name) display.CommandErr(app_dns.RemoveAll(app)) case "production": - fmt.Println("not yet implemented") + fmt.Printf(` +-------------------------------------------------------- +Production dns aliasing is not yet implemented. +-------------------------------------------------------- + +`) } } diff --git a/commands/info.go b/commands/info.go index 5cf02a62..3347f07d 100644 --- a/commands/info.go +++ b/commands/info.go @@ -37,6 +37,11 @@ func infoFn(ccmd *cobra.Command, args []string) { appModel, _ := models.FindAppBySlug(config.EnvID(), name) display.CommandErr(app.Info(env, appModel)) case "production": - fmt.Println("not yet implemented") + fmt.Printf(` +---------------------------------------------------------- +Showing production app information is not yet implemneted. +---------------------------------------------------------- + +`) } } diff --git a/commands/login.go b/commands/login.go index fa7aee69..3ddee7f5 100644 --- a/commands/login.go +++ b/commands/login.go @@ -15,12 +15,12 @@ var ( LoginCmd = &cobra.Command{ Use: "login", Short: "Authenticate your nanobox client with your nanobox.io account.", - Long: ` + Long: ` Authenticate with your nanobox account by passing the username and password in or using the following environment variables: NANOBOX_USERNAME NANOBOX_PASSWORD - `, - Run: loginFn, +`, + Run: loginFn, } // loginCmdFlags ... diff --git a/commands/server/server.go b/commands/server/server.go index 24c77946..28a908dd 100644 --- a/commands/server/server.go +++ b/commands/server/server.go @@ -30,7 +30,7 @@ const name = "nanobox-server" func serverFnc(ccmd *cobra.Command, args []string) { if !util.IsPrivileged() { - log.Fatal("server needs to run as privilaged user") + log.Fatal("server needs to run as a privileged user") return } // make sure things know im the server diff --git a/processors/configure_set.go b/processors/configure_set.go index 1abf99eb..3c1d33b8 100644 --- a/processors/configure_set.go +++ b/processors/configure_set.go @@ -1,6 +1,7 @@ package processors import ( + "fmt" "strconv" "github.com/nanobox-io/nanobox/models" @@ -40,7 +41,17 @@ func ConfigureSet(key, val string) error { config.CISyncVerbose = val == "true" || val == "t" || val == "1" case "anonymous": config.Anonymous = val == "true" || val == "t" || val == "1" + default: + fmt.Printf("'%s' is not a valid key.\n", key) + return nil } - return config.Save() + err := config.Save() + if err == nil { + fmt.Printf("Successfully set '%s'\n", key) + } else { + fmt.Printf("Failed to set '%s'\n", key) + } + + return err } diff --git a/processors/provider/bridge/setup.go b/processors/provider/bridge/setup.go index 24cd6730..c680b60a 100644 --- a/processors/provider/bridge/setup.go +++ b/processors/provider/bridge/setup.go @@ -75,7 +75,7 @@ func setupContainer() error { container, err := docker.CreateContainer(config) if err != nil { display.ErrorTask() - return util.ErrorAppend(err, "failed to create docker container") + return util.ErrorAppend(err, "failed to create bridge container") } display.StopTask() diff --git a/processors/run.go b/processors/run.go index 5494da45..e73ee87e 100644 --- a/processors/run.go +++ b/processors/run.go @@ -184,6 +184,7 @@ func watchFiles(envModel *models.Env, appModel *models.App) { boxfile := boxfile.New([]byte(appModel.DeployedBoxfile)) if boxfile.Node("run.config").BoolValue("fs_watch") && (provider.RequiresMount() || specialException()) { lumber.Info("watcher starting") + // todo: server.Watch to call the following, so we can pre-emptively set ulimit to much higher. go watch.Watch(container_generator.DevName(), envModel.Directory) } } diff --git a/util/provider/dockermachine.go b/util/provider/dockermachine.go index 0a9e77df..4206f7d1 100644 --- a/util/provider/dockermachine.go +++ b/util/provider/dockermachine.go @@ -73,11 +73,19 @@ func (machine DockerMachine) Valid() (error, []string) { case "linux": out, err := exec.Command("netstat", "-tln").CombinedOutput() if err != nil { - missingParts = append(missingParts, "netfs") - masterErr = fmt.Errorf("%s - failed to check for netfs - %q", masterErr.Error(), err.Error()) + missingParts = append(missingParts, "nfs-kernel-server") + if masterErr == nil { + masterErr = fmt.Errorf("failed to check for netfs - %s", err.Error()) + } else { + masterErr = fmt.Errorf("%s - failed to check for netfs - %s", masterErr.Error(), err.Error()) + } } else if !bytes.Contains(out, []byte("2049")) { - missingParts = append(missingParts, "netfs") - masterErr = fmt.Errorf("%s - missing or not running netfs - %q", masterErr.Error(), err.Error()) + missingParts = append(missingParts, "nfs-kernel-server") + if masterErr == nil { + masterErr = fmt.Errorf("missing or not running netfs") + } else { + masterErr = fmt.Errorf("%s - missing or not running netfs", masterErr.Error()) + } } if err := exec.Command("exportfs").Run(); err != nil {