MCPcopy
hub / github.com/keploy/keploy / monitorAgent

Method monitorAgent

pkg/platform/http/agent.go:1150–1164  ·  view source on GitHub ↗

monitorAgent monitors the agent process and handles cleanup

(clientCtx context.Context, agentCtx context.Context)

Source from the content-addressed store, hash-verified

1148
1149// monitorAgent monitors the agent process and handles cleanup
1150func (a *AgentClient) monitorAgent(clientCtx context.Context, agentCtx context.Context) {
1151 select {
1152 case <-clientCtx.Done():
1153 // Client context cancelled, stop the agent
1154 a.logger.Debug("Client context cancelled, stopping agent")
1155 a.stopAgent()
1156 case <-agentCtx.Done():
1157 // Agent context cancelled or agent stopped
1158 if errors.Is(agentCtx.Err(), context.Canceled) {
1159 a.logger.Info("Agent was stopped intentionally")
1160 } else {
1161 a.logger.Error("Agent stopped unexpectedly, client operations may be affected", zap.String("next_step", "check agent logs for panic/oom, ensure required capabilities/permissions, or rerun with --debug and verify the agent binary is compatible with the CLI"))
1162 }
1163 }
1164}
1165
1166func (a *AgentClient) Setup(ctx context.Context, cmd string, opts models.SetupOptions) error {
1167 isDockerCmd := utils.IsDockerCmd(utils.CmdType(opts.CommandType))

Callers 1

startAgentMethod · 0.95

Calls 4

stopAgentMethod · 0.95
DebugMethod · 0.65
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected