Skip to content

Commit

Permalink
Includes
Browse files Browse the repository at this point in the history
  • Loading branch information
brotherlogic committed Aug 17, 2020
1 parent c160f25 commit 5e1bcd1
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions dlog.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,38 @@
package goserver

import "fmt"
import (
"bufio"
"fmt"
"os"
"strings"
)

func (s *GoServer) hasScratch() bool {
file, err := os.Open("/proc/mounts")

if err != nil {
s.Log(fmt.Sprintf("Unable to read mounts: %v", err))
}
defer file.Close()

scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)

for scanner.Scan() {
fields := strings.Fields(scanner.Text())
if len(fields) > 2 && fields[1] == "/media/scratch" {
return true
}
}

return false

}

func (s *GoServer) prepDLog() {
s.Log(fmt.Sprintf("Prepping for Disk Logging"))
if s.hasScratch() {
s.Log(fmt.Sprintf("Prepping for Disk Logging"))
} else {
s.Log(fmt.Sprintf("Scratch not found, no disk logging"))
}
}

0 comments on commit 5e1bcd1

Please sign in to comment.