feat: add initial project structure with logging and watchdog service
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
This commit is contained in:
29
config.go
Normal file
29
config.go
Normal file
@@ -0,0 +1,29 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user