mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-21 10:43:36 +00:00
fix: Properly close command client WebSocket when disabling remotely
When the server disables command execution for an agent, we now properly call Close() on the command client to tear down the WebSocket connection. Previously we just set the pointer to nil which left the goroutine running with an orphaned connection.
This commit is contained in:
@@ -462,7 +462,10 @@ func (a *Agent) applyRemoteConfig(commandsEnabled bool) {
|
||||
} else if !commandsEnabled && currentlyEnabled {
|
||||
// Server disabled commands, but we have a command client running
|
||||
a.logger.Info().Msg("Server disabled command execution - stopping command client")
|
||||
// Signal stop (the command client will exit on next iteration)
|
||||
// Properly close the WebSocket connection to stop the client
|
||||
if err := a.commandClient.Close(); err != nil {
|
||||
a.logger.Debug().Err(err).Msg("Error closing command client connection")
|
||||
}
|
||||
a.commandClient = nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user