- Add debug server listen address and port configuration in config.json and config.go - Update main.go to use debug config values when in debug mode - Add logging for monitor add/remove commands in commandParse.go
56 lines
1.1 KiB
Go
56 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"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))
|
|
|
|
go func() {
|
|
err := socket.BootSocket(Type, listenAddr, listenPort)
|
|
if err != nil {
|
|
postLog.Fatal(fmt.Sprintf("Failed to initialize socket server: %v", err))
|
|
}
|
|
}()
|
|
|
|
select {}
|
|
}
|