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:
2026-04-02 21:56:40 +08:00
commit f6005cb324
10 changed files with 483 additions and 0 deletions

29
config.go Normal file
View 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
}
}