dashcam 1.4.7-beta → 1.4.9-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/topProcesses.js +39 -18
- package/package.json +1 -1
package/lib/topProcesses.js
CHANGED
|
@@ -193,34 +193,53 @@ async function getTopProcessesUnix(limit = 10) {
|
|
|
193
193
|
if (os.platform() === 'darwin') {
|
|
194
194
|
// macOS uses BSD ps - different syntax, no --sort option
|
|
195
195
|
// Use -r flag to sort by CPU usage
|
|
196
|
+
console.log('[topProcesses] Running macOS ps command');
|
|
196
197
|
const result = await execFileAsync('ps', [
|
|
197
198
|
'-Arco',
|
|
198
199
|
'pid,pcpu,pmem,comm'
|
|
199
200
|
], { encoding: 'utf8', timeout: 5000 });
|
|
200
201
|
stdout = result.stdout;
|
|
202
|
+
console.log('[topProcesses] macOS ps succeeded, output length:', stdout.length);
|
|
201
203
|
} else {
|
|
202
|
-
// Linux
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
204
|
+
// Linux - try different variations in order of preference
|
|
205
|
+
const psVariations = [
|
|
206
|
+
// Standard GNU ps with --sort
|
|
207
|
+
{ args: ['-eo', 'pid,pcpu,pmem,comm', '--sort=-pcpu'], name: 'GNU ps with --sort' },
|
|
208
|
+
// GNU ps without --sort (we'll sort in JS)
|
|
209
|
+
{ args: ['-eo', 'pid,pcpu,pmem,comm'], name: 'GNU ps without --sort' },
|
|
210
|
+
// BusyBox ps (minimal options)
|
|
211
|
+
{ args: ['-o', 'pid,pcpu,pmem,comm'], name: 'BusyBox ps' },
|
|
212
|
+
// Most basic ps command
|
|
213
|
+
{ args: ['aux'], name: 'basic ps aux' }
|
|
214
|
+
];
|
|
215
|
+
|
|
216
|
+
let psSuccess = false;
|
|
217
|
+
for (const variation of psVariations) {
|
|
218
|
+
try {
|
|
219
|
+
console.log(`[topProcesses] Trying: ${variation.name}`);
|
|
220
|
+
const result = await execFileAsync('ps', variation.args, {
|
|
221
|
+
encoding: 'utf8',
|
|
222
|
+
timeout: 5000
|
|
223
|
+
});
|
|
224
|
+
stdout = result.stdout;
|
|
225
|
+
console.log(`[topProcesses] ${variation.name} succeeded, output length:`, stdout.length);
|
|
226
|
+
logger.debug(`ps command succeeded: ${variation.name}`, { outputLength: stdout.length });
|
|
227
|
+
psSuccess = true;
|
|
228
|
+
break;
|
|
229
|
+
} catch (err) {
|
|
230
|
+
console.log(`[topProcesses] ${variation.name} failed:`, err.message);
|
|
231
|
+
// Try next variation
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (!psSuccess) {
|
|
236
|
+
throw new Error('All ps command variations failed');
|
|
220
237
|
}
|
|
221
238
|
}
|
|
222
239
|
|
|
240
|
+
console.log('[topProcesses] Parsing ps output...');
|
|
223
241
|
const processes = parsePsOutput(stdout, limit);
|
|
242
|
+
console.log('[topProcesses] Parsed', processes.length, 'processes');
|
|
224
243
|
logger.debug('Parsed processes from ps output', {
|
|
225
244
|
processCount: processes.length,
|
|
226
245
|
firstProcess: processes[0]
|
|
@@ -228,6 +247,8 @@ async function getTopProcessesUnix(limit = 10) {
|
|
|
228
247
|
|
|
229
248
|
return processes;
|
|
230
249
|
} catch (error) {
|
|
250
|
+
console.error('[topProcesses] FATAL ERROR getting top processes:', error.message);
|
|
251
|
+
console.error('[topProcesses] Error stack:', error.stack);
|
|
231
252
|
logger.warn('Failed to get top processes on Unix', {
|
|
232
253
|
error: error.message,
|
|
233
254
|
stack: error.stack,
|