Files
WatchDog_Linux-systemd/main.go
NanamiAdmin 58a8efc17a refactor(socket): decouple command handling and add message sending
- Move command handler to variable for better flexibility
- Add SendMsg function for sending messages through socket
- Fix missing return statements in command execution
- Improve error handling in monitor exception reporting
2026-04-28 19:55:45 +08:00

61 lines
1.2 KiB
Go

package main
import (
"Watchdog_Linux-systemd/command"
"Watchdog_Linux-systemd/postLog"
"Watchdog_Linux-systemd/socket"
"fmt"
)
var (
listenAddr = "127.0.0.1"
listenPort = 10080
Type = "tcp"
)
type SoftwareInfo struct {
Name string
Version string
Developer string
BuildVer int16
Description string
BuildType string
}
var softwareInfo SoftwareInfo = SoftwareInfo{
Name: "Watchdog_Linux-systemd",
Version: "0.0.1",
Developer: "Super-frpc",
BuildVer: 1,
Description: "Super-frpc Watchdog service for Linux systemd",
BuildType: "Debug",
}
var isDebug bool
var DebugListenAddr string
var DebugListenPort int
func main() {
loadConfig()
if isDebug == true {
postLog.SetDebugMode(true)
listenAddr = DebugListenAddr
listenPort = DebugListenPort
}
postLog.Info(fmt.Sprintf("%s %s (Build %d.%s) by %s", softwareInfo.Name, softwareInfo.Version, softwareInfo.BuildVer, softwareInfo.BuildType, softwareInfo.Developer))
// Set command handler
socket.CommandHandler = command.ExecuteCommand
// End of command handler
go func() {
err := socket.BootSocket(Type, listenAddr, listenPort)
if err != nil {
postLog.Fatal(fmt.Sprintf("Failed to initialize socket server: %v", err))
}
}()
select {}
}