Skip to content

Instantly share code, notes, and snippets.

@christopherreay
Created November 29, 2018 15:16
Show Gist options
  • Save christopherreay/1880461039fe5d39c40ecbc8bab61bb3 to your computer and use it in GitHub Desktop.
Save christopherreay/1880461039fe5d39c40ecbc8bab61bb3 to your computer and use it in GitHub Desktop.
// this is from package.json:
`
"interfaceDebugPartial": "AT_INSPECTOR_DYNAMIC=TRUE node apps/interface.js 2>&1 | tee logs/interfaceDebugPartial.log",
`
this.setDebugging = function(trueFalse, done)
{
if (done === undefined || done === null)
{ done = ()=>{};
}
if (trueFalse === undefined || trueFalse === null) trueFalse = true;
if (trueFalse === true)
{
if (
// ! process.env.AT_INSPECTOR_RUNNING
// &&
process.env.AT_INSPECTOR_DYNAMIC === "TRUE"
)
{
// swtich on debugging
process.env.AT_INSPECTOR_RUNNING = true;
// Debugger attached.
// Debugger listening on ws://127.0.0.1:9229/0687f419-a1bf-4598-8944-e826e60581a3
// For help, see: https://nodejs.org/en/docs/inspector
atRoot.ls("@: atSrc: setDebugging: waiting for the debugging to attach");
let debuggerWaitTimeout;
let catchUserDebugging =
() =>
{
let t = false;
// let timeBeforeDebuggerStatement = Date.now();
debugger;
// let timeAfterDebuggerStatement = Date.now();
if (t === true)
{
clearTimeout(debuggerWaitTimeout);
done();
}
else
{ setTimeout( () => { debuggerWaitTimeout = setTimeout( catchUserDebugging, 200 ) }, 500);
}
};
debuggerWaitTimeout = setTimeout(catchUserDebugging, 200);
process.kill(process.pid, "SIGUSR1");
process.env.AT_CONSOLE_SYNTAXHIGHLIGHTING = "INSPECTOR";
}
else
{ atRoot.ls("@: mochaMeta: no need to send debugger signal to node process");
toReturn = done();
}
}
else
{
}
atRoot.ls("@@@@@@@","@: atRoot: setDebugging called: " + trueFalse);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment