diff --git a/config.yaml b/config.yaml index 9f9b45b..c454e34 100644 --- a/config.yaml +++ b/config.yaml @@ -15,8 +15,7 @@ ports: desc: Testing-3 status: 1 logs: - inlogs: /root/serial-port-websocket/logs/ - outlogs: /root/serial-port-websocket/logs/ + inlogs: /var/serial-port-websocket/logs/ maxsize: 50 #Megabytes maxbackups: 10 #Number of Files maxage: 30 #Number of Days @@ -29,5 +28,5 @@ serverconfig: - name: https enable: 1 #1-Enable 2-Disable port: 8084 - sslcert: /root/serial-port-websocket/server.crt + sslcert: /etc/serial-port-websocket/server.crt sslkey: /etc/serial-port-websocket/server.key diff --git a/main.go b/main.go index 2b36bd3..3537cca 100644 --- a/main.go +++ b/main.go @@ -89,7 +89,14 @@ func initialize() error { if err != nil { return err } - + // Check logs dir exist or not, if not create dir + if _, err := os.Stat(config.Logs.Inlogs); os.IsNotExist(err) { + log.Printf("Proided logs dir: %s does not exist. Creating it.", config.Logs.Inlogs) + err = os.MkdirAll(config.Logs.Inlogs, os.ModePerm) + if err != nil { + return err + } + } // redirect stdErr to stacktrace files fname := config.Logs.Inlogs + "stacktrace-" + strconv.Itoa(os.Getpid()) f, err := os.Create(fname) diff --git a/ui/home.html b/ui/home.html index bbddf61..20803c0 100644 --- a/ui/home.html +++ b/ui/home.html @@ -228,6 +228,10 @@ // Create Table from JSON response function CreateTableFromJSON(JSONResponse) { document.getElementById("response").innerHTML = ""; + JSONConvert = JSON.parse(JSONResponse); + if (JSONConvert.Ports == null) { + return + } // BUILD Paths var col = ["Device Name", "Port", "Baudrate", "", "Port Config"]; @@ -249,7 +253,6 @@ // Populate table from JSON Data. var col = []; - JSONConvert = JSON.parse(JSONResponse); var tb = table.createTBody(); tb.id += "myTable" for (var i = 0; i < JSONConvert.Ports.length; i++) {