GeezerVison is showing github.com — doc: add note for handling signal events in trace events · nodejs/node@0805068
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: doc/api/tracing.md +11Lines changed: 11 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -80,6 +80,17 @@ string that supports `${rotation}` and `${pid}`: |
80 | 80 | node --trace-event-categories v8 --trace-event-file-pattern '${pid}-${rotation}.log' server.js |
81 | 81 | ``` |
82 | 82 |
|
| 83 | +To guarantee that the log file is properly generated after signal events like |
| 84 | +`SIGINT`, `SIGTERM`, or `SIGBREAK`, make sure to have the appropriate handlers |
| 85 | +in your code, such as: |
| 86 | + |
| 87 | +```js |
| 88 | +process.on('SIGINT', function onSigint() { |
| 89 | + console.info('Received SIGINT.'); |
| 90 | + process.exit(130); // Or applicable exit code depending on OS and signal |
| 91 | +}); |
| 92 | +``` |
| 93 | + |
83 | 94 | The tracing system uses the same time source |
84 | 95 | as the one used by `process.hrtime()`. |
85 | 96 | However the trace-event timestamps are expressed in microseconds, |
|