MCPcopy Index your code
hub / github.com/callstack/agent-device / cleanupStaleAppLogProcesses

Function cleanupStaleAppLogProcesses

src/daemon/app-log-process.ts:98–120  ·  view source on GitHub ↗
(sessionsDir: string)

Source from the content-addressed store, hash-verified

96}
97
98export function cleanupStaleAppLogProcesses(sessionsDir: string): void {
99 if (!fs.existsSync(sessionsDir)) return;
100 const entries = fs.readdirSync(sessionsDir, { withFileTypes: true });
101 for (const entry of entries) {
102 if (!entry.isDirectory()) continue;
103 const pidPath = path.join(sessionsDir, entry.name, APP_LOG_PID_FILENAME);
104 if (!fs.existsSync(pidPath)) continue;
105 try {
106 const meta = parsePidFile(fs.readFileSync(pidPath, 'utf8'));
107 if (meta && shouldTerminateStoredProcess(meta)) {
108 try {
109 process.kill(meta.pid, 'SIGTERM');
110 } catch {
111 // process already gone
112 }
113 }
114 } catch {
115 // ignore malformed pid files
116 } finally {
117 clearPidFile(pidPath);
118 }
119 }
120}

Callers 2

startDaemonRuntimeFunction · 0.90
app-log.test.tsFile · 0.90

Calls 4

parsePidFileFunction · 0.85
clearPidFileFunction · 0.85
killMethod · 0.45

Tested by

no test coverage detected