From 9e4445314f1a015f61aad481e75d9cab4f70dd13 Mon Sep 17 00:00:00 2001 From: kekskurse Date: Mon, 20 Sep 2021 23:52:07 +0200 Subject: [PATCH] fix error handling --- config.yml | 2 +- main.go | 8 +++----- template/index.html | 4 +++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/config.yml b/config.yml index 011bd31..7fc2e04 100644 --- a/config.yml +++ b/config.yml @@ -3,7 +3,7 @@ http: checks: hdd: - max_percent: 100 + max_percent: 10 load: max_load_1: 10 max_load_5: 8 diff --git a/main.go b/main.go index 19deff9..94e8c36 100644 --- a/main.go +++ b/main.go @@ -24,12 +24,10 @@ func main() { http.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) { _, gloableRes := checkSystem() - if gloableRes { - writer.Write([]byte(s)) - } else { - http.Error(writer, s, http.StatusInternalServerError) + if gloableRes == false { + writer.WriteHeader(http.StatusInternalServerError) } - writer.Write([]byte("Fatal Error")) + writer.Write([]byte(s)) }) http.HandleFunc("/data.json", handler) err := http.ListenAndServe(c.HTTP.Listen, nil) diff --git a/template/index.html b/template/index.html index e906ded..b2adf28 100644 --- a/template/index.html +++ b/template/index.html @@ -51,8 +51,10 @@ console.log("ajax done") handleData(data) }).always(function(data) { + console.log("always") if(data.responseText != "") { - handleData(data) + console.log(data.responseText) + handleData(data.responseText) } setTimeout("getData();", 10000);