refactor(socket): decouple command handling and add message sending
- Move command handler to variable for better flexibility - Add SendMsg function for sending messages through socket - Fix missing return statements in command execution - Improve error handling in monitor exception reporting
This commit is contained in:
@@ -50,7 +50,8 @@ func ExecuteCommand(input string) error {
|
||||
err := monitor.AddServiceMonitor(serviceName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to add service monitor: %v", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
case "monitor.remove":
|
||||
serviceName := getContent(input, "serviceName")
|
||||
@@ -60,9 +61,11 @@ func ExecuteCommand(input string) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to remove service monitor: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
case "watchdog.shutdown":
|
||||
os.Exit(0)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown command")
|
||||
}
|
||||
Reference in New Issue
Block a user