From cffa74f9cfe4ef21d829fd7e41ab0df82b1755b9 Mon Sep 17 00:00:00 2001 From: emile Date: Thu, 24 Sep 2015 11:39:18 +0200 Subject: [PATCH] Exit on permission denied --- Makefile | 1 + traefik.go | 17 +++++++++++++++-- web.go | 10 ++++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index c715199be..937374627 100644 --- a/Makefile +++ b/Makefile @@ -54,5 +54,6 @@ dist: mkdir dist run-dev: + go generate go build ./traefik diff --git a/traefik.go b/traefik.go index 66a2820e7..820ef2367 100644 --- a/traefik.go +++ b/traefik.go @@ -21,6 +21,7 @@ import ( "time" fmtlog "log" "github.com/mailgun/oxy/cbreaker" + "net" ) var ( @@ -168,9 +169,21 @@ func main() { go func() { if len(gloablConfiguration.CertFile) > 0 && len(gloablConfiguration.KeyFile) > 0 { - srv.ListenAndServeTLS(gloablConfiguration.CertFile, gloablConfiguration.KeyFile) + err := srv.ListenAndServeTLS(gloablConfiguration.CertFile, gloablConfiguration.KeyFile) + if (err!= nil ){ + netOpError, ok := err.(*net.OpError) + if ok && netOpError.Err.Error() != "use of closed network connection" { + log.Fatal("Error creating server: ", err) + } + } } else { - srv.ListenAndServe() + err := srv.ListenAndServe() + if (err!= nil ){ + netOpError, ok := err.(*net.OpError) + if ok && netOpError.Err.Error() != "use of closed network connection" { + log.Fatal("Error creating server: ", err) + } + } } }() log.Notice("Started") diff --git a/web.go b/web.go index e6d4e7415..bb516dce3 100644 --- a/web.go +++ b/web.go @@ -46,9 +46,15 @@ func (provider *WebProvider) Provide(configurationChan chan<- *Configuration) { go func() { if len(provider.CertFile) > 0 && len(provider.KeyFile) > 0 { - http.ListenAndServeTLS(provider.Address,provider.CertFile, provider.KeyFile, systemRouter) + err := http.ListenAndServeTLS(provider.Address,provider.CertFile, provider.KeyFile, systemRouter) + if (err!= nil ){ + log.Fatal("Error creating server: ", err) + } } else { - http.ListenAndServe(provider.Address, systemRouter) + err := http.ListenAndServe(provider.Address, systemRouter) + if (err!= nil ){ + log.Fatal("Error creating server: ", err) + } } }() }