Skip to content

Commit

Permalink
Inital commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tejaskumar.kasundra committed Jun 3, 2021
1 parent b4a4bcd commit 953f4a7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
5 changes: 2 additions & 3 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
9 changes: 8 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion ui/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -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"];

Expand All @@ -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++) {
Expand Down

0 comments on commit 953f4a7

Please # to comment.