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:
1 parent
3a0b591d5e
commit
58a8efc17a
4 files changed
+67
-28
No files matched your search
@@ -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