Skip to content

Instantly share code, notes, and snippets.

@IgorGee
Created August 5, 2017 03:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IgorGee/a4118efa4c1f287d76a634a234d205a9 to your computer and use it in GitHub Desktop.
Save IgorGee/a4118efa4c1f287d76a634a234d205a9 to your computer and use it in GitHub Desktop.
const spawn = require('child_process').spawn
const exec = require('child_process').exec
const fork = require('child_process').fork
const miner = spawn("./miner.sh")
const shouldRestart = (line) => {
const launchFailString = new RegExp(/unspecified launch failure/)
const staleDataString = new RegExp(/Submitting stale solution/)
return launchFailString.test(line) || staleDataString.test(line)
}
miner.stdout.on('data', (data) => {
if (shouldRestart(data)) {
// exec('reboot') or fork("./stdoutScanner.js")
}
})
miner.stderr.on('data', (data) => {
console.log(`stderr: ${data}`);
});
miner.on('close', (code) => {
console.log(`Miner exited with code: ${code}`)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment