@marcel91200 / caddy Mirror · read-only / commits / 4eb5fc54
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 14, 05:15 UTC

Better error handling in CLI commands

Matthew Holt committed Jul 7, 2019 at 16:39 UTC 4eb5fc541b12ef942b0ac06694686d44a4c18a4e
1 file changed +6 -4
cmd/commands.go
+6 -4
@@ -100,7 +100,9 @@ func cmdStart() (int, error) {
100 for {
101 conn, err := ln.Accept()
102 if err != nil {
103 - log.Println(err)
103 + if !strings.Contains(err.Error(), "use of closed network connection") {
104 + log.Println(err)
105 + }
106 break
107 }
108 err = handlePingbackConn(conn, expect)
@@ -114,8 +116,8 @@ func cmdStart() (int, error) {
116
117 // in another goroutine, we await the failure of the child process
118 go func() {
117 - err = cmd.Wait() // don't send on this line! Wait blocks, but send starts before it unblocks
118 - exit <- err // sending on separate line ensures select won't trigger until after Wait unblocks
119 + err := cmd.Wait() // don't send on this line! Wait blocks, but send starts before it unblocks
120 + exit <- err // sending on separate line ensures select won't trigger until after Wait unblocks
121 }()
122
123 // when one of the goroutines unblocks, we're done and can exit
@@ -154,7 +156,7 @@ func cmdRun() (int, error) {
156 // start the admin endpoint along with any initial config
157 err := caddy.StartAdmin(config)
158 if err != nil {
157 - return 0, fmt.Errorf("starting caddy administration endpoint: %v", err)
159 + return 1, fmt.Errorf("starting caddy administration endpoint: %v", err)
160 }
161 defer caddy.StopAdmin()
162