-
Notifications
You must be signed in to change notification settings - Fork 0
/
demos.process.js
37 lines (30 loc) · 1.18 KB
/
demos.process.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
*
* Package: concurrency.js
* Author: Ganesh B
* Description: npm module to work with concurrency - worker threads and worker processes easily using simple functions and script files
* Install: npm i concurrency.js --save
* Github: https://github.com/ganeshkbhat/concurrency
* npmjs Link: https://www.npmjs.com/package/concurrency.js
* File: demos.process.js
* File Description:
*
*/
/* eslint no-console: 0 */
'use strict';
const path = require("path");
let { _concurrencyProcesses } = require("../index.js");
let filename = path.join(process.cwd(), "src\\worker.process.js");
_concurrencyProcesses(
path.join(filename), {
data: {
message: "Testing data",
url: "https://www.google.com"
}
}, true).then((d) => {
console.log("Data fetched: ", JSON.stringify(d));
}).catch((e) => {
console.log(e.toString()); /* setTimeout(() => { process.exit(e); }, 5000) */
});
setTimeout(() => console.log(`demo.processes.js: Run file PID ${process.pid}: Interval 2: 10000 `, process.pid), 10000);
setTimeout(() => console.log(`demo.processes.js: Closing process ${process.pid}: Timeout 1: 10000 `, process.exit()), 20000);