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:
5
main.go
5
main.go
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Watchdog_Linux-systemd/command"
|
||||
"Watchdog_Linux-systemd/postLog"
|
||||
"Watchdog_Linux-systemd/socket"
|
||||
"fmt"
|
||||
@@ -44,6 +45,10 @@ func main() {
|
||||
}
|
||||
postLog.Info(fmt.Sprintf("%s %s (Build %d.%s) by %s", softwareInfo.Name, softwareInfo.Version, softwareInfo.BuildVer, softwareInfo.BuildType, softwareInfo.Developer))
|
||||
|
||||
// Set command handler
|
||||
socket.CommandHandler = command.ExecuteCommand
|
||||
// End of command handler
|
||||
|
||||
go func() {
|
||||
err := socket.BootSocket(Type, listenAddr, listenPort)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user