From bc23a66bb08d1fb5623c632e8b52cd87b9db2ed1 Mon Sep 17 00:00:00 2001 From: Tim Schuster Date: Wed, 15 Mar 2017 14:37:37 +0100 Subject: [PATCH] Last minute touch-ups --- http/admin/handler.go | 1 + http/board/handler.go | 1 + http/server.go | 2 +- main.go | 18 ++++++++++++++---- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/http/admin/handler.go b/http/admin/handler.go index a8e630a..36e39e6 100644 --- a/http/admin/handler.go +++ b/http/admin/handler.go @@ -35,6 +35,7 @@ func LoadTemplates() error { if err != nil { panic(err) } + return nil } // Router sets up the Administration Panel diff --git a/http/board/handler.go b/http/board/handler.go index 5f0fd18..f3e3f54 100644 --- a/http/board/handler.go +++ b/http/board/handler.go @@ -69,6 +69,7 @@ func LoadTemplates() error { if err != nil { return err } + return nil } func Router(r chi.Router) { diff --git a/http/server.go b/http/server.go index 4cc3d32..4f41c83 100644 --- a/http/server.go +++ b/http/server.go @@ -77,5 +77,5 @@ func Start(config *config.Config) error { Addr: config.ListenOn, MaxHeaderBytes: 1 * 1024 * 1024, } - srv.ListenAndServe() + return srv.ListenAndServe() } diff --git a/main.go b/main.go index dd61254..6f96e8d 100644 --- a/main.go +++ b/main.go @@ -1,18 +1,28 @@ package main import ( - "fmt" "go.rls.moe/nyx/config" "go.rls.moe/nyx/http" + "log" + "os" + "time" ) func main() { c, err := config.Load() if err != nil { - fmt.Printf("Could not read configuration: %s\n", err) + log.Printf("Could not read configuration: %s\n", err) return } - fmt.Println("Starting Server") - http.Start(c) + log.Println("Starting Server") + if err := http.Start(c); err != nil { + log.Printf("Could not start server or server crashed: %s\n", err) + log.Printf("Waiting 10 seconds before dying...") + time.Sleep(10 * time.Second) + log.Printf("Exiting") + os.Exit(1) + return + } + os.Exit(0) }