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

simple-process-manager

v0.4.2

Published

Simple process manager

Downloads

14

Readme

Simple Process Manager

Simple Node.js process manager.

$ npm i simple-process-manager

Usage

If you want to start 3 instances of a background process:

$ pm start ./workers/background-command.js --total 3

The process manager will ensure that the process stays alive.

The worker has to expose a start and a stop functions.

module.exports = {
    start(config) {
        //initialize your worker...
    },
    close() {
        return new Promise(resolve => {
            //clean up code...
        });
    }
};
$ pm info
name:        example
worker:      /Users/peperone/simple-process-manager/server
instances:   8
description: Example showing how to run CLI process manager
pid:         19365
pids: 
  - 19366
  - 19367
  - 19368
  - 19369
  - 19370
  - 19371
  - 19372
  - 19373
$ pm restart background-command

Signals

SIGUSR2

If you want to restart your workers- say because you changed the script source code- you can use a signal using the leader's pid:

$ kill -SIGUSR2 <pid>
SIGTERM

This will terminate all workers immediately without waiting for them to clean up.

$ kill -SIGTERM <pid>
SIGINT

This will terminate all workers but will wait for them to clean up up to timeout.

$ kill -SIGINT <pid>

Changelog

  • 2019-09-01 v0.4.2 Bug fixes
  • 2019-09-01 v0.4.0 Added CLI commands to manage metadata and restart workers
  • 2019-08-31 v0.3.0 Enable restarting workers using SIGUSR2 signal
  • 2019-08-04 v0.2.0 Clean up, promisify, and expose CLI
  • 2019-08-03 v0.1.0 Initial release

TODO

  • [ ] Expose as a core.io-cli command plugin
  • [ ] Create CLI so we can:
    • [x] list current workers
    • [x] restart workers
    • [ ] remove workers
  • [ ] Pass metadata file location as option
  • [ ] Memory graph: Show CLI UI with memory graph per worker
  • [ ] Enable passing env to worker
  • [ ] Abstract transport so we can communicate with workers using:
    • [ ] IPC
    • [ ] Unix socket
    • [ ] TCP socket
    • [ ] MQTT
  • [x] Give each cluster leader a unique ID/name
  • [ ] Provide interface so cluster leaders are addressable
    • [ ] Locally
    • [ ] Remotely
  • [ ] Create a worker shell so we can wrap scripts that do not expose start/close.
  • [ ] Enable loading custom configurations to pass along to workers

License

® 2019 License MIT by goliatone