Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Code to run if we're in the master process
- if (cluster.isMaster) {
- // Count the machine's CPUs
- var cpuCount = require('os').cpus().length;
- console.log('Master cluster setting up ' + cpuCount + ' workers...')
- // Create a worker for each CPU
- for (var i = 0; i < cpuCount; i += 1) {
- cluster.fork();
- }
- cluster.on('online', function(worker){
- console.log('Worker ' + worker.process.pid + ' is online!')
- });
- cluster.on('exit', function(worker, code, signal) {
- // The worker is dead. He's a stiff, bereft of life,
- // he rests in peace.
- // He's pushing up the daisies. He expired and went
- // to meet his maker.
- // He's bleedin' demised. This worker is no more.
- // He's an ex-worker.
- // Oh, look, a shiny new one.
- // Norwegian Blue - beautiful plumage.
- console.log('Worker ' + worker.process.pid + ' died with code: ' + code + ', and signal: ' + signal);
- console.log('Starting a new worker');
- cluster.fork();
- });
- await redisInterface.init()
- await webInterface.init(web3,accountConfig,poolConfig,redisInterface)
- await tokenInterface.init(redisInterface,web3,accountConfig,poolConfig,pool_env)
- await peerInterface.init(web3,accountConfig,poolConfig,redisInterface,tokenInterface,pool_env) //initJSONRPCServer();
- await diagnosticsManager.init(redisInterface,webInterface,peerInterface)
- await webServer.init(https_enabled,webInterface,peerInterface)
- // Code to run if we're in a worker process
- } else {
- var worker_id = cluster.worker.id
- if(worker_id == 1)
- {
- await redisInterface.init()
- await tokenInterface.init(redisInterface,web3,accountConfig,poolConfig,pool_env)
- await peerInterface.init(web3,accountConfig,poolConfig,redisInterface,tokenInterface,pool_env) //initJSONRPCServer();
- tokenInterface.update();
- peerInterface.update();
- }
- if(worker_id >= 2)
- {
- await redisInterface.init()
- await tokenInterface.init(redisInterface,web3,accountConfig,poolConfig,pool_env)
- await peerInterface.init(web3,accountConfig,poolConfig,redisInterface,tokenInterface,pool_env) //initJSONRPCServer();
- //tokenInterface.update();
- peerInterface.listenForJSONRPC(8586);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement