MCPcopy
hub / github.com/keploy/keploy / stopAgent

Method stopAgent

pkg/platform/http/agent.go:1127–1147  ·  view source on GitHub ↗

stopAgent stops the agent process gracefully.

()

Source from the content-addressed store, hash-verified

1125
1126// stopAgent stops the agent process gracefully.
1127func (a *AgentClient) stopAgent() {
1128 a.mu.Lock()
1129 defer a.mu.Unlock()
1130 if a.agentCancel != nil {
1131 a.agentCancel()
1132 a.agentCancel = nil
1133 }
1134
1135 if a.agentCmd != nil && a.agentCmd.Process != nil {
1136 pid := a.agentCmd.Process.Pid
1137 a.logger.Debug("Stopping keploy agent", zap.Int("pid", pid))
1138 }
1139
1140 // If PTY is active, close it to unblock stdin/stdout copies
1141 if a.agentPTY != nil {
1142 // Use the utils function to gracefully stop PTY
1143 if err := agentUtils.StopPTYCommand(a.agentPTY, a.logger); err != nil {
1144 a.logger.Debug("failed to stop PTY command", zap.Error(err))
1145 }
1146 }
1147}
1148
1149// monitorAgent monitors the agent process and handles cleanup
1150func (a *AgentClient) monitorAgent(clientCtx context.Context, agentCtx context.Context) {

Callers 2

monitorAgentMethod · 0.95
SetupMethod · 0.95

Calls 2

DebugMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected