New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

redirect-stdio

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redirect-stdio

Utilities for redirecting stdout and stderr

latest
npmnpm
Version
1.0.0
Version published
Weekly downloads
18
-40%
Maintainers
1
Weekly downloads
 
Created
Source

redirect-stdio

Utilities for redirecting node process stdout and stderr.

Note: Only works on MacOS and Linux.

Motivation

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 to access.log.2 and then calls SIGUSR2 on your node process. But your node process is logging to stdout, and can't exactly "reopen" process.stdout.

With redirect-stio, you can:

  • use pathFromFd to find where your process's stdout is actually going
  • on SIGUSR2, re-open the log path you just found, and write that file descriptor over the old one to rotate logs

Usage

const { reopenStdout, reopenStderr } = require('redirect-stdio');

process.on('SIGUSR2', function() {
  reopenStdout();
  reopenStderr();
});

License

Copyright 2023 Movable, Inc. See LICENSE.md.

FAQs

Package last updated on 24 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts