0.0.10 • Published 7 years ago

controlled-cluster v0.0.10

Weekly downloads
-
License
ISC
Repository
-
Last release
7 years ago

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?');
  }
})
0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago