From 44164c0abed04df31510a215ed06812002f6b0c4 Mon Sep 17 00:00:00 2001 From: Gabriel Trujillo Date: Fri, 21 Jan 2022 18:53:43 -0500 Subject: [PATCH] doc: add note for handling signal events in trace events MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs: https://github.com/nodejs/node/issues/14802 PR-URL: https://github.com/nodejs/node/pull/41438 Reviewed-By: James M Snell Reviewed-By: Adrian Estrada Reviewed-By: Mary Marchini Reviewed-By: Gerhard Stöbich Reviewed-By: Santiago Gimeno --- doc/api/tracing.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/api/tracing.md b/doc/api/tracing.md index d0b5ac4250e978..df76d985f71dbe 100644 --- a/doc/api/tracing.md +++ b/doc/api/tracing.md @@ -80,6 +80,17 @@ string that supports `${rotation}` and `${pid}`: node --trace-event-categories v8 --trace-event-file-pattern '${pid}-${rotation}.log' server.js ``` +To guarantee that the log file is properly generated after signal events like +`SIGINT`, `SIGTERM`, or `SIGBREAK`, make sure to have the appropriate handlers +in your code, such as: + +```js +process.on('SIGINT', function onSigint() { + console.info('Received SIGINT.'); + process.exit(130); // Or applicable exit code depending on OS and signal +}); +``` + The tracing system uses the same time source as the one used by `process.hrtime()`. However the trace-event timestamps are expressed in microseconds,