Add error reporting on http server startup failure

master
Bas Kloosterman 11 months ago
parent 5dc9f6c1b0
commit 2600aa03a5
  1. 5
      dvzaservice/main.go
  2. 4
      dvzaservice/srv.go
  3. 5
      whiteboxservice/main.go
  4. 6
      whiteboxservice/srv.go

@ -6,6 +6,7 @@ import (
"io/ioutil"
"log"
"net"
"net/http"
"os"
"os/signal"
"sync"
@ -96,7 +97,9 @@ func main() {
go func() {
wg.Add(1)
srv.ListenAndServe()
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
panic(err)
}
}()
<-stop

@ -34,12 +34,12 @@ func (srv *UIService) Addr() string {
return srv.srv.Addr
}
func (srv *UIService) ListenAndServe() {
func (srv *UIService) ListenAndServe() error {
if !srv.inited {
srv.init()
}
log.Printf("Listening on %v\n", srv.srv.Addr)
srv.srv.ListenAndServe()
return srv.srv.ListenAndServe()
}
func (srv *UIService) Shutdown(ctx context.Context) error {

@ -7,6 +7,7 @@ import (
"io/ioutil"
"log"
"net"
"net/http"
"os"
"os/signal"
"sync"
@ -103,7 +104,9 @@ func main() {
go func() {
wg.Add(1)
srv.ListenAndServe()
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
panic(err)
}
}()
<-stop

@ -39,12 +39,12 @@ func (srv *UIService) Addr() string {
return srv.srv.Addr
}
func (srv *UIService) ListenAndServe() {
func (srv *UIService) ListenAndServe() error {
if !srv.inited {
srv.init()
}
log.Println("Listening on %v", srv.srv.Addr)
srv.srv.ListenAndServe()
log.Printf("Listening on %v\n", srv.srv.Addr)
return srv.srv.ListenAndServe()
}
func (srv *UIService) Shutdown(ctx context.Context) error {

Loading…
Cancel
Save