MCPcopy Index your code
hub / github.com/coder/coder / executeBackground

Function executeBackground

coderd/x/chatd/chattool/execute.go:151–177  ·  view source on GitHub ↗

executeBackground starts a process in the background and returns immediately with the process ID.

(
	ctx context.Context,
	conn workspacesdk.AgentConn,
	command string,
	workDir string,
	env map[string]string,
)

Source from the content-addressed store, hash-verified

149// executeBackground starts a process in the background and
150// returns immediately with the process ID.
151func executeBackground(
152 ctx context.Context,
153 conn workspacesdk.AgentConn,
154 command string,
155 workDir string,
156 env map[string]string,
157) fantasy.ToolResponse {
158 resp, err := conn.StartProcess(ctx, workspacesdk.StartProcessRequest{
159 Command: command,
160 WorkDir: workDir,
161 Env: env,
162 Background: true,
163 })
164 if err != nil {
165 return errorResult(fmt.Sprintf("start background process: %v", err))
166 }
167
168 result := ExecuteResult{
169 Success: true,
170 BackgroundProcessID: resp.ID,
171 }
172 data, err := json.Marshal(result)
173 if err != nil {
174 return fantasy.NewTextErrorResponse(err.Error())
175 }
176 return fantasy.NewTextResponse(string(data))
177}
178
179// executeForeground starts a process and waits for its
180// completion, enforcing the configured timeout.

Callers 1

executeToolFunction · 0.85

Calls 4

errorResultFunction · 0.70
StartProcessMethod · 0.65
MarshalMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected