fix(watchdog): now the client could successfully send more msgs to watchdog instead of the only connection msg

- Add debug logging for watchdog operations
- Standardize message format for instance operations
- Improve TCP message handling with proper line termination
- Enhance error handling in watchdog operations
- Add proper cleanup of recvChan in sendMsg
- Update response handling in instance handlers
This commit is contained in:
2026-04-07 23:29:07 +08:00
parent 37c10f1c07
commit 2426933f49
3 changed files with 102 additions and 63 deletions
+30 -4
View File
@@ -2,23 +2,45 @@ package watchdog
import (
"fmt"
"super-frpc/postLog"
)
func AddInstance(serviceName string) bool {
postLog.Debug(fmt.Sprintf("[watchdog] Add service monitor: %s", serviceName))
if !IsConnected() {
return false
}
message := fmt.Sprintf("[instance.add] <serviceName>%s</serviceName>", serviceName)
message := fmt.Sprintf("[monitor.add] <serviceName>%s</serviceName>", serviceName)
response, err := sendMsg(message, 3)
if err != nil {
return false
} else if response == "success" {
return true
}
return response == "success"
return false
}
func RemoveInstance(serviceName string) bool {
postLog.Debug(fmt.Sprintf("[watchdog] Remove service monitor: %s", serviceName))
if !IsConnected() {
return false
}
message := fmt.Sprintf("[monitor.remove] <serviceName>%s</serviceName>", serviceName)
response, err := sendMsg(message, 3)
if err != nil {
return false
} else if response == "success" {
return true
}
return false
}
func CloseInstance(serviceName string) bool {
postLog.Debug(fmt.Sprintf("[watchdog] Remove service monitor: %s", serviceName))
if !IsConnected() {
return false
}
@@ -27,9 +49,11 @@ func RemoveInstance(serviceName string) bool {
response, err := sendMsg(message, 3)
if err != nil {
return false
} else if response == "success" {
return true
}
return response == "success"
return false
}
func Close() bool {
@@ -41,7 +65,9 @@ func Close() bool {
response, err := sendMsg(message, 3)
if err != nil {
return false
} else if response == "success" {
return true
}
return response == "success"
return false
}