summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-07-07 16:39:21 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2019-07-07 16:39:21 -0600
commit4eb5fc541b12ef942b0ac06694686d44a4c18a4e (patch)
treede7d28f3d7fe89c0b055373e749d974ff2d466a2
parent42acdad9e541192185fe2ce64e72430ab032ca16 (diff)
Better error handling in CLI commands
-rw-r--r--cmd/commands.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/cmd/commands.go b/cmd/commands.go
index 5e0217a..ad0339f 100644
--- a/cmd/commands.go
+++ b/cmd/commands.go
@@ -100,7 +100,9 @@ func cmdStart() (int, error) {
for {
conn, err := ln.Accept()
if err != nil {
- log.Println(err)
+ if !strings.Contains(err.Error(), "use of closed network connection") {
+ log.Println(err)
+ }
break
}
err = handlePingbackConn(conn, expect)
@@ -114,8 +116,8 @@ func cmdStart() (int, error) {
// in another goroutine, we await the failure of the child process
go func() {
- err = cmd.Wait() // don't send on this line! Wait blocks, but send starts before it unblocks
- exit <- err // sending on separate line ensures select won't trigger until after Wait unblocks
+ err := cmd.Wait() // don't send on this line! Wait blocks, but send starts before it unblocks
+ exit <- err // sending on separate line ensures select won't trigger until after Wait unblocks
}()
// when one of the goroutines unblocks, we're done and can exit
@@ -154,7 +156,7 @@ func cmdRun() (int, error) {
// start the admin endpoint along with any initial config
err := caddy.StartAdmin(config)
if err != nil {
- return 0, fmt.Errorf("starting caddy administration endpoint: %v", err)
+ return 1, fmt.Errorf("starting caddy administration endpoint: %v", err)
}
defer caddy.StopAdmin()