feat(watchdog): add exception handling and webhook integration

- Implement exception handling in TCP client to process error messages
- Add webhook functionality to send notifications for exceptions
- Introduce utility functions for string parsing
- Update config with webhook template
This commit is contained in:
2026-04-28 15:46:31 +08:00
parent ac51641e93
commit 0890c8136f
4 changed files with 116 additions and 3 deletions
+12 -3
View File
@@ -6,6 +6,7 @@ import (
"net"
"strings"
"super-frpc/postLog"
"super-frpc/utils"
"sync"
"time"
)
@@ -108,15 +109,23 @@ func recvMsg() {
if len(data) > 0 {
line := strings.TrimSpace(string(data))
if len(line) > 0 {
select {
case recvChan <- line:
case recvChan <- line:
default:
// drop the message
}
// Here add logic to handle the message
if !isResponseMessage(line) {
postLog.Debug(fmt.Sprintf("[Watchdog] TCP Socket received message: %s", line))
cmdType := utils.GetCmdType(line)
if cmdType == "Exception" {
exceptionType := utils.GetCmdParams(line, "exceptionType")
serviceName := utils.GetCmdParams(line, "serviceName")
errorMsg := utils.GetCmdParams(line, "errorMsg")
postLog.Error(fmt.Sprintf("[Watchdog] Exception[%s]: %s, %s", serviceName, exceptionType, errorMsg))
exceptionHandle(exceptionType, serviceName, errorMsg)
}
}
}
}