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

Method list

agent/agentproc/process.go:243–267  ·  view source on GitHub ↗

list returns info about all tracked processes. Exited processes older than exitedProcessReapAge are removed. If chatID is non-empty, only processes belonging to that chat are returned.

(chatID string)

Source from the content-addressed store, hash-verified

241// If chatID is non-empty, only processes belonging to that
242// chat are returned.
243func (m *manager) list(chatID string) []workspacesdk.ProcessInfo {
244 m.mu.Lock()
245 defer m.mu.Unlock()
246
247 now := m.clock.Now()
248 infos := make([]workspacesdk.ProcessInfo, 0, len(m.procs))
249 for id, proc := range m.procs {
250 info := proc.info()
251 // Reap processes that exited more than 5 minutes ago
252 // to prevent unbounded map growth.
253 if !info.Running && info.ExitedAt != nil {
254 exitedAt := time.Unix(*info.ExitedAt, 0)
255 if now.Sub(exitedAt) > exitedProcessReapAge {
256 delete(m.procs, id)
257 continue
258 }
259 }
260 // Filter by chatID if provided.
261 if chatID != "" && proc.chatID != chatID {
262 continue
263 }
264 infos = append(infos, info)
265 }
266 return infos
267}
268
269// signal sends a signal to a running process. It returns
270// sentinel errors errProcessNotFound and errProcessNotRunning

Callers 1

handleListProcessesMethod · 0.45

Calls 3

infoMethod · 0.80
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected