From 99f3758fa45845bce39b0ee424737607042efa81 Mon Sep 17 00:00:00 2001 From: Gabriel Trujillo Date: Fri, 7 Jan 2022 15:50:09 -0500 Subject: [PATCH 1/2] doc: add note for handling signal events in trace events Refs: https://github.com/nodejs/node/issues/14802 --- doc/api/tracing.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/api/tracing.md b/doc/api/tracing.md index d0b5ac4250e978..ba2fe3d9c07c2c 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(); +}); +``` + The tracing system uses the same time source as the one used by `process.hrtime()`. However the trace-event timestamps are expressed in microseconds, From 2a517086cce39b7f89fb3f42ed022a6722e49b90 Mon Sep 17 00:00:00 2001 From: Gabriel Trujillo Date: Tue, 18 Jan 2022 13:38:05 -0500 Subject: [PATCH 2/2] doc: added exit code and comment to code example --- doc/api/tracing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/tracing.md b/doc/api/tracing.md index ba2fe3d9c07c2c..df76d985f71dbe 100644 --- a/doc/api/tracing.md +++ b/doc/api/tracing.md @@ -87,7 +87,7 @@ in your code, such as: ```js process.on('SIGINT', function onSigint() { console.info('Received SIGINT.'); - process.exit(); + process.exit(130); // Or applicable exit code depending on OS and signal }); ```