Skip to content

Conversation

@XK4MiLX
Copy link
Member

@XK4MiLX XK4MiLX commented Feb 12, 2026

Summary

  • Replace shelljs dependency with native Node.js child_process.execFile
  • Modernize JavaScript: replace all var with let/const
  • Add runCommand() and runShellCommand() helper functions for consistent command execution
  • Replace echo $HOME shell commands with native os.homedir()
  • Fix function ordering to prevent reference errors
  • Implement module-level variable declarations for proper scope handling
  • Fix fs.writeFile callback issue by using fs.writeFileSync
  • Remove shelljs from package.json dependencies
  • Fix install hang on legacy nodes

Benefits

  • Performance: Native Node.js APIs eliminate shelljs wrapper overhead
  • Maintainability: Consistent error handling and timeout patterns
  • Reliability: Graceful error handling ensures watchdog never crashes
  • Modern JavaScript: let/const improves code clarity and prevents hoisting issues

- Replace shelljs with child_process.execFile for better security
- Add runCommand() for system commands with parameter arrays
- Add runShellCommand() for shell commands with pipes/redirects
- Fix $USER path variable to use os.homedir()
- Convert config initialization to async function pattern
- Add graceful error handling - watchdog never crashes
- Use modern let/const instead of var
- Add proper main() entry point with error recovery
- Remove shelljs dependency from package.json

All 79 shell.exec calls replaced with appropriate runCommand variants.
Complete refactoring of watchdog.js to use native Node.js child_process:
- Implemented runCommand() and runShellCommand() functions with proper error handling
- Replaced all 79+ shell.exec() calls with runCommand/runShellCommand
- Removed shelljs dependency from package.json

Bug fixes:
- Fixed function ordering: moved compareVersions and checkCloudUI before job_creator to prevent reference errors
- Fixed missing stdout destructuring in checkCloudUI and error_line
- Fixed config object literal syntax (semicolons to commas)
- Added missing semicolons on lines 1011, 1012, 1427
- Replaced echo $HOME with os.homedir() for path resolution

Modernization:
- Replaced all var declarations with let/const at appropriate scope levels
- Added module-level variables for flux_check variables used across try/catch blocks
- Used const for notification variables (emoji_title, info_type, etc.)
- Used let for function-scoped variables
- Increased checkCloudUI timeout from 30s to 120s for CloudUI download

Error handling improvements:
- Graceful config initialization - watchdog continues on config errors
- Graceful Arcane checks - watchdog continues if checks fail
- Never crashes - all errors are caught and logged
Complete refactoring of watchdog.js to use native Node.js child_process:
- Implemented runCommand() and runShellCommand() functions with proper error handling
- Replaced all 79+ shell.exec() calls with runCommand/runShellCommand
- Removed shelljs dependency from package.json

Bug fixes:
- Fixed function ordering: moved compareVersions and checkCloudUI before job_creator to prevent reference errors
- Fixed missing stdout destructuring in checkCloudUI and error_line
- Fixed config object literal syntax (semicolons to commas)
- Added missing semicolons on lines 1011, 1012, 1427
- Replaced echo $HOME with os.homedir() for path resolution

Modernization:
- Replaced all var declarations with let/const at appropriate scope levels
- Added module-level variables for flux_check variables used across try/catch blocks
- Used const for notification variables (emoji_title, info_type, etc.)
- Used let for function-scoped variables
- Increased checkCloudUI timeout from 30s to 120s for CloudUI download

Error handling improvements:
- Graceful config initialization - watchdog continues on config errors
- Graceful Arcane checks - watchdog continues if checks fail
- Never crashes - all errors are caught and logged
- Change console message from "Component update detected!" to "System stabilization period after component update!" to accurately reflect timing (message appears after update completion, not during)
- Fix fluxbench log path to use os.homedir() instead of hardcoded '/home/$USER/.fluxbenchmark/debug.log'
- Minor whitespace cleanup
@XK4MiLX XK4MiLX changed the title [WIP] Refactor/use run command Refactor/use run command Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant