-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemos.cluster.loadbalancer.threading.js
58 lines (53 loc) · 1.52 KB
/
demos.cluster.loadbalancer.threading.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
*
* 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.cluster.loadbalancer.threading.js
* File Description:
*
*/
/* eslint no-console: 0 */
'use strict';
var path = require("path");
var loadbalancer = require("../index").loadbalancer;
var httpSocketServer = loadbalancer.sockets.httpSocketServer;
var express = require("./express-app");
loadbalancer.threading({
"server": express,
"protocol": "http",
"createCerts": true,
"host": "localhost",
"proxy": {
"proxy": true,
"protocol": "http",
"host": "localhost",
"port": 7000,
"proxyHost": "",
"proxyPort": 9000
},
"certs": {
"key": "../certs/ssl.key",
"cert": "../certs/ssl.cert"
},
"port": 8000,
"ws": true,
"processes": 5,
"threads": 10,
"mainProcessCallback": () => { },
"forkCallback": (opts, pr) => {
// console.log(opts, pr);
// console.log(opts);
httpSocketServer(opts);
},
"callbacks": {
"wsOnData": null,
"wsOnEnd": null,
"wsUpgrade": null,
"server": null,
"listen": null
}
}, [{ filename: path.join(__filename), options: {} }])