fix(watchdog): fix watchdog unable to send webhook and simplify the parsing of json config
- Change webhook config headers and body from map to string format - Move command parsing logic to separate function in command.go - Add debug logging for webhook operations - Improve exception handling with proper JSON parsing - Simplify config loading logic with default values
This commit is contained in:
@@ -3,6 +3,7 @@ package watchdog
|
||||
import (
|
||||
"fmt"
|
||||
"super-frpc/postLog"
|
||||
"super-frpc/utils"
|
||||
)
|
||||
|
||||
func AddInstance(serviceName string) bool {
|
||||
@@ -70,4 +71,17 @@ func Close() bool {
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func parseCommand(cmd string) (result string, err error) {
|
||||
cmdType := utils.GetCmdType(cmd)
|
||||
if cmdType == "Exception" {
|
||||
// Watchdog msg: [Exception] <exceptionType>...</exceptionType> <serviceName>...</serviceName> <errorMsg>...</errorMsg>
|
||||
exceptionType := utils.GetCmdParams(cmd, "exceptionType")
|
||||
serviceName := utils.GetCmdParams(cmd, "serviceName")
|
||||
errorMsg := utils.GetCmdParams(cmd, "errorMsg")
|
||||
postLog.Error(fmt.Sprintf("[Watchdog] Exception[%s]: %s, %s", serviceName, exceptionType, errorMsg))
|
||||
exceptionHandle(exceptionType, serviceName, errorMsg)
|
||||
}
|
||||
return "", nil
|
||||
}
|
||||
Reference in New Issue
Block a user