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

process-babysitter

v1.4.0

Published

Manages long-running processes during development with GUI console.

Downloads

9

Readme

Process Babysitter

The babysitter is meant to alleviate the tedium of starting & managing multiple processes when developing distributed applications. It has been used daily to manage 30+ simultaneous processes with negligible overhead. This manager is meant to be used FOR DEVELOPMENT ONLY. Please use something better for production such systemd, upstart, forever, pm2, Docker, etc.

npm install -g process-babysitter
mkdir config
touch config/default.json
# set up config files
process-babysitter ./config
open http://localhost:9876/   # port is configurable, see below

Configuration

The babysitter uses Node Config (docs) to manage configuration files. This allows multiple configurations to reside in the same directory & extend the base config for various environments & deployments. Some fields can be Lodash templates as noted below.

The configuration should contain:

  • server: Server settings
    • port: Port to bind to for HTTP & Socket.io access.
  • template_vars: Dictionary of variables to make available to process field templates.
  • processes: Dictionary of processes to babysit. Each processes key should be the same as its id field.
    • id: Process id. Used as id in HTTP routes.
    • enabled: Boolean whether the process should be ignored.
    • name: Human name for process. Displayed in web UI.
    • command: Templated command to run.
    • cwd: Templated value for the subprocess working directory.
    • args: Array of templated arguments for the subprocess (everything that follows the command).
    • env: Map of environment variable name to value to use for that var. If the value starts with $, it will be assumed to refer to an existing env var and use its value at run time.

Example default.json:

{
  "server": {
    "port": 9876
  },
  "template_vars": {
    "services_dir": "/Users/me/dev/my-stuff/"
  },
  "processes": {
    "api": {
      "id": "api",
      "enabled": true,
      "name": "API Service",
      "command": "node",
      "cwd": "<%= services_dir %>my-api",
      "args": ["<%= services_dir %>my-api/index.js"],
      "env": {
        "MY_VAR_1": "foo",
        "MY_VAR_2": "$BAR"
      }
    },
    "mongodb": {
      "id": "mongodb",
      "enabled": true,
      "name": "MongoDB Server",
      "command": "mongod"
    }
  }
}

It should be noted that child processes will inherit the environment variables set when the babysitter is started. If env vars are specified for the process, they will override the babysitter's env vars for that process.

Use the standard node-config variables (NODE_ENV, NODE_APP_INSTANCE, etc) to change which config files are loaded. The babysitter will pass on any process.env variables except the following so as to not interfere with child processes.

  • NODE_CONFIG_DIR
  • NODE_ENV
  • NODE_APP_INSTANCE

In this manner it is possible to have many project configurations in the same directory (if desired).

Web UI

The web UI is meant to give an easy interface to start, stop & view process output. Each registered process is listed as a collapsable section and can be started/stopped individually or all at once. The UI interacts with the server via the REST API & Socket.io events. See the source (it's quite small) for the HTTP routes & socket.io events.

The UI itself should be fairly self-explanatory with stdout on the left & stderr on the right. The "pause" button will pause stdout/stderr for all processes (in the UI, the server still collects it) until clicked again. The "clear" button will remove all logs for all processes in the UI & server. Both the UI & server keep the last ~100 lines (may be configurable in the future) of output.

open http://localhost:9876/

UI Screenshot

Development

npm version x.y.z -m '<release notes>'
npm publish