# controlled-cluster

> The first world solution to spawning child workers

Latest version **0.0.10** (published 2017-03-04) · ISC license · 0 weekly downloads

## Install

```sh
npm install controlled-cluster
pnpm add controlled-cluster
yarn add controlled-cluster
bun add controlled-cluster
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.10 |
| Published | 2017-03-04 |
| First published | 2017-02-28 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | presidentpearce |

## Links

- npm: https://www.npmjs.com/package/controlled-cluster
- npm.io page: https://npm.io/package/controlled-cluster

## Dependencies (2)

- [cluster](https://npm.io/package/cluster.md) ^0.7.7
- [jsonfile](https://npm.io/package/jsonfile.md) ^2.4.0

## Recent versions

- 0.0.10 (latest) — 2017-03-04
- 0.0.9 — 2017-03-02
- 0.0.8 — 2017-03-02
- 0.0.7 — 2017-03-02
- 0.0.6 — 2017-03-02
- 0.0.5 — 2017-03-02
- 0.0.4 — 2017-03-02
- 0.0.3 — 2017-03-02
- 0.0.2 — 2017-03-02
- 0.0.1 — 2017-03-02
- 1.0.8 — 2017-02-28
- 1.0.7 — 2017-02-28
- 1.0.6 — 2017-02-28
- 1.0.5 — 2017-02-28
- 1.0.4 — 2017-02-28
- … 4 more at https://npm.io/package/controlled-cluster/versions

## README

The first world solution to spawning child workers

#Installation
###npm i controlled-cluster --save

#Usage
The code below will run three processes in parallel.
It is your responsibility to check the number of cpus available.

```
const controlledCluster = require('controlled-cluster');

const processes = [
  (callback) => {
    console.log("running child process");
    setTimeout(() => {
      //do your work here
      let error = false;
      callback(error)
    }, 1000)
  },
  (callback) => {
    console.log("running child process");
    setTimeout(() => {
      //do your work here
      let error = false;
      callback(error)
    }, 1400)
  },
  (callback) => {
    console.log("running child process")
    setTimeout(() => {
      //do your work here
      let error = false;
      callback(error)
    }, 2000)
  }
];

controlledCluster(processes, (err) => {
  if (!err) {
    console.log("They just toss us away like yesterday's jam.");
  } else {
    console.log(err);
    console.log('Have you tried forcing an unexpected reboot?');
  }
})
```

---
_Source: https://npm.io/package/controlled-cluster · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
