Reputation: 11
We can start debugger in nodejs using kill -USR1 PID
. How can we disable it using any signal or any other way without terminating the worker?
Reference - https://nodejs.org/en/docs/guides/debugging-getting-started/#enable-inspector
Upvotes: 1
Views: 1552
Reputation: 527
While SIGUSR1 is used to start the debug inspector (equivalent to running node with the --inspect
flag), you can customize SIGUSR2 to close the inspector without killing the process.
Adding something like this to your main app should add that behavior.
const inspector = require('inspector');
process.on('SIGUSR2', () => {
console.log('Received SIGUSR2. Closing inspector.');
inspector.close();
});
https://nodejs.org/api/inspector.html#inspector_inspector_close
Upvotes: 2