MCPcopy Create free account
hub / github.com/anus-dev/ANUS / cleanup

Function cleanup

scripts/telemetry_utils.js:376–412  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

374) {
375 let cleanedUp = false;
376 const cleanup = () => {
377 if (cleanedUp) return;
378 cleanedUp = true;
379
380 console.log('\n👋 Shutting down...');
381
382 manageTelemetrySettings(false, null, originalSandboxSetting);
383
384 const processes = getProcesses ? getProcesses() : [];
385 processes.forEach((proc) => {
386 if (proc && proc.pid) {
387 const name = path.basename(proc.spawnfile);
388 try {
389 console.log(`🛑 Stopping ${name} (PID: ${proc.pid})...`);
390 process.kill(proc.pid, 'SIGTERM');
391 console.log(`✅ ${name} stopped.`);
392 } catch (e) {
393 if (e.code !== 'ESRCH') {
394 console.error(`Error stopping ${name}: ${e.message}`);
395 }
396 }
397 }
398 });
399
400 const logFileDescriptors = getLogFileDescriptors
401 ? getLogFileDescriptors()
402 : [];
403 logFileDescriptors.forEach((fd) => {
404 if (fd) {
405 try {
406 fs.closeSync(fd);
407 } catch (_) {
408 /* no-op */
409 }
410 }
411 });
412 };
413
414 process.on('exit', cleanup);
415 process.on('SIGINT', () => process.exit(0));

Callers 1

registerCleanupFunction · 0.70

Calls 1

manageTelemetrySettingsFunction · 0.85

Tested by

no test coverage detected