How to disable debugging with a signal in nodejs?

Viewed 432
1 Answers

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

Related