Browse Source

log to stderr when the bot cannot bind http port

master 1.0.6
Nicolas Massé 4 years ago
parent
commit
ec7fcf63bb
  1. 5
      http.go
  2. 6
      main.go

5
http.go

@ -1,7 +1,6 @@
package main
import (
"log"
"net/http"
"path"
"strings"
@ -23,7 +22,7 @@ func ShiftPath(p string) (head, tail string) {
return p[1:i], p[i:]
}
func ServeWebInterface(listenAddr string, webInterface http.Handler, staticFiles http.FileSystem) {
func ServeWebInterface(listenAddr string, webInterface http.Handler, staticFiles http.FileSystem) error {
router := http.NewServeMux()
router.Handle("/js/", http.FileServer(staticFiles))
router.Handle("/css/", http.FileServer(staticFiles))
@ -33,5 +32,5 @@ func ServeWebInterface(listenAddr string, webInterface http.Handler, staticFiles
Addr: listenAddr,
Handler: router,
}
log.Fatal(server.ListenAndServe())
return server.ListenAndServe()
}

6
main.go

@ -297,5 +297,9 @@ func main() {
initLogFile()
go photoBot.Process()
ServeWebInterface(viper.GetString("WebInterface.Listen"), securityFrontend, statikFS)
err = ServeWebInterface(viper.GetString("WebInterface.Listen"), securityFrontend, statikFS)
if err != nil {
panic(err)
}
}

Loading…
Cancel
Save