MCPcopy Index your code
hub / github.com/coder/mux / cleanup

Method cleanup

src/node/services/backgroundProcessManager.ts:1348–1365  ·  view source on GitHub ↗

* Clean up all processes for a workspace. * Terminates running processes and removes from memory. * Output directories are left on disk (cleaned by OS for /tmp, or on workspace deletion for local).

(workspaceId: string)

Source from the content-addressed store, hash-verified

1346 * Output directories are left on disk (cleaned by OS for /tmp, or on workspace deletion for local).
1347 */
1348 async cleanup(workspaceId: string): Promise<void> {
1349 log.debug(`BackgroundProcessManager.cleanup(${workspaceId}) called`);
1350 const matching = Array.from(this.processes.values()).filter(
1351 (p) => p.workspaceId === workspaceId
1352 );
1353
1354 // Terminate all running processes
1355 await Promise.all(matching.map((p) => this.terminate(p.id)));
1356
1357 // Remove from memory (output dirs left on disk for OS/workspace cleanup)
1358 // All per-process state (outputBytesRead, outputLock) is stored in the
1359 // BackgroundProcess object, so cleanup is automatic when we delete here.
1360 for (const p of matching) {
1361 this.processes.delete(p.id);
1362 }
1363
1364 log.debug(`Cleaned up ${matching.length} process(es) for workspace ${workspaceId}`);
1365 }
1366}

Callers

nothing calls this directly

Calls 3

terminateMethod · 0.95
debugMethod · 0.80
deleteMethod · 0.45

Tested by

no test coverage detected