Skip to content

A node module that helps spawn child processes with deterministic controls

Notifications You must be signed in to change notification settings

mjbrisebois/node-subprocess

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

new SubProcess( binary, ...args )

A node module that helps spawn child processes with deterministic controls.

Overview

This module is intended to provide more deterministic controls to the native child_process library.

Features

  • Close subprocess if parent process exits or receives SIGINT
  • Line emitter for stdout and stderr instead of data chunks
  • Await spawn success or error with timeout
  • Await certain output with timeout
  • Send signal and await close with a timeout
  • Deterministic kill with timeout
  • Await close event

Install

npm i @whi/subprocess

Basic Usage

let subprocess = new SubProcess( "python3", "-um", "http.server", "8888" );

subprocess.stdout( line => {
    console.log( line );
});

subprocess.stderr( line => {
    console.error( line );
});

await subprocess.ready();

await subprocess.output("Serving HTTP on 0.0.0.0 port 8888");

await subprocess.stop();

API Reference

See docs/API.md

Contributing

See CONTRIBUTING.md

About

A node module that helps spawn child processes with deterministic controls

Resources

Stars

Watchers

Forks

Packages

No packages published