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.
Files changed (2) hide show
  1. package/lib/topProcesses.js +39 -18
  2. package/package.json +1 -1
@@ -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 uses GNU ps - try --sort first, fallback to sorting in JS
203
- try {
204
- const result = await execFileAsync('ps', [
205
- '-eo',
206
- 'pid,pcpu,pmem,comm',
207
- '--sort=-pcpu'
208
- ], { encoding: 'utf8', timeout: 5000 });
209
- stdout = result.stdout;
210
- logger.debug('ps command succeeded with --sort', { outputLength: stdout.length });
211
- } catch (sortError) {
212
- // Some Linux systems (like BusyBox or older ps) don't support --sort
213
- logger.debug('ps --sort not supported, using unsorted output', { error: sortError.message });
214
- const result = await execFileAsync('ps', [
215
- '-eo',
216
- 'pid,pcpu,pmem,comm'
217
- ], { encoding: 'utf8', timeout: 5000 });
218
- stdout = result.stdout;
219
- logger.debug('ps command succeeded without --sort', { outputLength: stdout.length });
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dashcam",
3
- "version": "1.4.7-beta",
3
+ "version": "1.4.9-beta.0",
4
4
  "description": "Minimal CLI version of Dashcam desktop app",
5
5
  "main": "bin/dashcam.js",
6
6
  "bin": {