I
I
Ivan Smirnov2019-07-21 15:38:17
Node.js
Ivan Smirnov, 2019-07-21 15:38:17

How to catch the output of a process?

For example: there was a process - and then an error occurred in it, which led to a crash, or I or pm2 (for example) decided to turn off the process. This is the moment I need to catch

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
de1m, 2019-07-21
@de1m

Try this, it works for me when I press "ctrl+c"

process.on('SIGINT', function () {
  console.log("exit");
  process.nextTick(function () { process.exit(0); });
});

And I looked, here they write that for "SIGKILL" it is impossible to make an event.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question