Implement basic watchdog service for Linux systemd with: - Configuration loading - Logging system with database support - WebSocket log broadcasting - TCP server for agent communication - Project setup with Go modules
30 lines
577 B
Go
30 lines
577 B
Go
package main
|
|
|
|
|
|
import (
|
|
"Watchdog_Linux-systemd/postLog"
|
|
"encoding/json"
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
var Config struct {
|
|
DebugMode bool `json:"debugMode"`
|
|
}
|
|
|
|
func loadConfig() {
|
|
configFile, err := os.Open("config.json")
|
|
if err != nil {
|
|
postLog.Fatal(fmt.Sprintf("Failed to open config file: %v, err: %v", configFile, err))
|
|
}
|
|
defer configFile.Close()
|
|
decoder := json.NewDecoder(configFile)
|
|
if err := decoder.Decode(&Config); err != nil {
|
|
postLog.Fatal(fmt.Sprintf("Failed to decode config file: %v, err: %v", configFile, err))
|
|
}
|
|
|
|
if Config.DebugMode {
|
|
isDebug = true
|
|
}
|
|
}
|