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

Function main

scripts/local_telemetry.js:72–218  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

70`;
71
72async function main() {
73 // 1. Ensure binaries are available, downloading if necessary.
74 // Binaries are stored in the project's .anus/otel/bin directory
75 // to avoid modifying the user's system.
76 if (!fileExists(BIN_DIR)) fs.mkdirSync(BIN_DIR, { recursive: true });
77
78 const otelcolPath = await ensureBinary(
79 'otelcol-contrib',
80 'open-telemetry/opentelemetry-collector-releases',
81 (version, platform, arch, ext) =>
82 `otelcol-contrib_${version}_${platform}_${arch}.${ext}`,
83 'otelcol-contrib',
84 false, // isJaeger = false
85 ).catch((e) => {
86 console.error(`��� Error getting otelcol-contrib: ${e.message}`);
87 return null;
88 });
89 if (!otelcolPath) process.exit(1);
90
91 const jaegerPath = await ensureBinary(
92 'jaeger',
93 'jaegertracing/jaeger',
94 (version, platform, arch, ext) =>
95 `jaeger-${version}-${platform}-${arch}.${ext}`,
96 'jaeger',
97 true, // isJaeger = true
98 ).catch((e) => {
99 console.error(`🛑 Error getting jaeger: ${e.message}`);
100 return null;
101 });
102 if (!jaegerPath) process.exit(1);
103
104 // 2. Kill any existing processes to ensure a clean start.
105 console.log('🧹 Cleaning up old processes and logs...');
106 try {
107 execSync('pkill -f "otelcol-contrib"');
108 console.log('✅ Stopped existing otelcol-contrib process.');
109 } catch (_e) {} // eslint-disable-line no-empty
110 try {
111 execSync('pkill -f "jaeger"');
112 console.log('✅ Stopped existing jaeger process.');
113 } catch (_e) {} // eslint-disable-line no-empty
114 try {
115 if (fileExists(OTEL_LOG_FILE)) fs.unlinkSync(OTEL_LOG_FILE);
116 console.log('✅ Deleted old collector log.');
117 } catch (e) {
118 if (e.code !== 'ENOENT') console.error(e);
119 }
120 try {
121 if (fileExists(JAEGER_LOG_FILE)) fs.unlinkSync(JAEGER_LOG_FILE);
122 console.log('✅ Deleted old jaeger log.');
123 } catch (e) {
124 if (e.code !== 'ENOENT') console.error(e);
125 }
126
127 let jaegerProcess, collectorProcess;
128 let jaegerLogFd, collectorLogFd;
129

Callers 1

local_telemetry.jsFile · 0.70

Calls 5

fileExistsFunction · 0.90
ensureBinaryFunction · 0.90
manageTelemetrySettingsFunction · 0.90
registerCleanupFunction · 0.90
waitForPortFunction · 0.90

Tested by

no test coverage detected