npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

processhost

v1.0.0

Published

a ridiculously simple process host

Downloads

27

Readme

processhost

Simple, cross-platform, process hosting for Node, adapted from [Anvil]'s(https://github.com/anviljs/anvil.js) processhost.

The most useful features are:

  • Reliably kills child processes on host process exit
  • Reliably restarts crashed child processes
  • Apply limits to restart behavior

API

var processes = require( "processhost" )();

configuration

Configuration hash has the following options. Only command and args are required.

{
	command: "", // this will probably be "node"
	args: [], // the command line args for the process, i.e. your script
	[cwd]: "", // defaults to current working directory
	[killSignal]: "" | [ "" ], // not required, defaults to "SIGTERM", can provide an array
	[stdio]: "inherit" | "ignore" | "pipe" // determines if the process will write to the console
	[env]: {}, // defaults to the process.env, should be simple hash
	[restart]: true, // control whether or not the process restarts after a start or restart call
	[restartLimit]: 1, // number of allowed restarts
	[restartWindow]: 100 // duration (in ms) of tolerance window
}

Notes

  1. restartWindow defaults to undefined - this results in limitless restarts
  1. stdio defaults to "inherit" causing child processes to share the parents stdout/stderr

create( processAlias, configuration )

Creates a new process without starting it.

processes.create( "myProcess", { command: "node", args: [ "./index.js" ], cwd: "./src" } );

restart( [processAlias] )

If a processAlias is provided, only starts|restarts the matching process. Otherwise, this will start|restart ALL processes that have been defined.

processes.restart(); // restart all

processes.restart( 'myApp' ); // restart only 'myApp'

setup( processesHash )

Used to define and potentially start multiple processes in a single call.

processes.setup( {
	"one": { ... },
	"two": { ... },
	"three": { ... }
} );

Note

To have the processes started automatically, add a start: true to the config block.

start( processAlias, [configuration] )

If no configuration is provided, this will start|restart the matching process. If a configuration is provided, this will create and start a new process.

processes.start( "myProcess", { command: "node", args: [ "./index.js" ], cwd: "./src" } );

stop( [processAlias] )

If no processAlias is provided, stops all running processes, otherwise it stops the specified process if it exists and is running.

processes.stop();

Events

You can subscribe to the following process level events off the process host.

  • [processAlias].crashed - the process has exited unexpectedly
  • [processAlias].failed - the process has exceeded the set tolerance
  • [processAlias].restarting - the process is restarting
  • [processAlias].started - the process has started
  • [processAlias].stderr
  • [processAlias].stdout
  • [processAlias].stopped - the process has exited after stop was called

Note

The stderr and stdout events cannot fire unless you set stdio to "pipe" in the config hash.