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:
+12
-3
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user