Utilities for redirecting stdout and stderr
npm install redirect-stdioUtilities for redirecting node process stdout and stderr.
Note: Only works on MacOS and Linux.
Imagine you have a node app that logs to stdout and a bash script that
runs your node process like this:
```
node myapp.js >> access.log
Later, you want to add logrotate, which moves access.log toaccess.log.2 and then calls SIGUSR2 on your node process. But yourprocess.stdout
node process is logging to stdout, and can't exactly "reopen".
With redirect-stio, you can:pathFromFd
* use to find where your process's stdout is actually goingSIGUSR2
* on , re-open the log path you just found, and write that file
descriptor over the old one to rotate logs
`javascript
const { reopenStdout, reopenStderr } = require('redirect-stdio');
process.on('SIGUSR2', function() {
reopenStdout();
reopenStderr();
});
``
Copyright 2023 Movable, Inc. See LICENSE.md.