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

multi-child-process

v1.1.4

Published

multi-child-process module for node

Downloads

68

Readme

multi-child-process

NPM version Downloads

NPM

A multi-child-process module for Node.js job.

Usage

Installation

You can install using npm.

npm install multi-child-process

Run tests

npm test

Examples:

The process pool needs to be initialized before using child processes. The default size of the process pool is the number of cpus. The parameter passed must be a positive integer, but capped at 10. If you do need a larger process pool size, you can modify the source code.

var pool = require('multi-child-process');
var procPool = new pool.initPool(3);//default: the number of cpus

Now init child process, these arguments must be passed:

pool.initChildProc(workPath, jobname, jobArgObject, cb);
  • workPath(string) : workModule of absolute path, like __dirname+'/logic.js'
  • jobname(string) : like 'module.exports.jobname=jobname' in the workPath
  • jobArgObject(Object): arguments that job function need, like {key:value}
  • cb(function) : callback function
//./main.js
pool.initChildProc(__dirname+'/logic.js', jobname, jobArgObject, function(err,ret){
//err: error of child process or job 
//ret: result of job function callback 
});

//./logic.js
function jobname(jobArgObject,callback){}
module.exports.jobname=jobname;

If child processes pool has been inited, this pool.isInited() will be true.

pool.isInited();

If all child processes are all available, this message event 'isAllAvail' will be emitted.

procPool.on('isAllAvail',cb);

If all child processes are all available, this pool.isAllAvail() will be true.

pool.isAllAvail();

Return the number of occupied processes.

pool.actiProcNum();

Return the size of child process pool.

pool.totalProcNum();

After finishing child process jobs, if you are sure that process pool is no longer needed, pool.closePool(cb) can be used. But it is suggested that you are listening to the message event 'isAllAvail' before using pool.closePool(cb). Argument cb is callback function.

pool.closePool(cb);