Advertisement
Guest User

tokenpoolinit

a guest
Apr 23rd, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   // Code to run if we're in the master process
  2.       if (cluster.isMaster) {
  3.  
  4.           // Count the machine's CPUs
  5.           var cpuCount = require('os').cpus().length;
  6.  
  7.           console.log('Master cluster setting up ' + cpuCount + ' workers...')
  8.          
  9.           // Create a worker for each CPU
  10.           for (var i = 0; i < cpuCount; i += 1) {
  11.               cluster.fork();
  12.           }
  13.  
  14.           cluster.on('online', function(worker){
  15.             console.log('Worker ' + worker.process.pid + ' is online!')
  16.           });
  17.  
  18.           cluster.on('exit', function(worker, code, signal) {
  19.             // The worker is dead. He's a stiff, bereft of life,
  20.             // he rests in peace.
  21.             // He's pushing up the daisies. He expired and went
  22.             // to meet his maker.
  23.             // He's bleedin' demised. This worker is no more.
  24.             // He's an ex-worker.
  25.  
  26.             // Oh, look, a shiny new one.
  27.             // Norwegian Blue - beautiful plumage.
  28.             console.log('Worker ' + worker.process.pid + ' died with code: ' + code + ', and signal: ' + signal);
  29.             console.log('Starting a new worker');
  30.             cluster.fork();
  31.           });
  32.  
  33.  
  34.            await redisInterface.init()
  35.            await webInterface.init(web3,accountConfig,poolConfig,redisInterface)
  36.            await tokenInterface.init(redisInterface,web3,accountConfig,poolConfig,pool_env)
  37.            await peerInterface.init(web3,accountConfig,poolConfig,redisInterface,tokenInterface,pool_env) //initJSONRPCServer();
  38.            await diagnosticsManager.init(redisInterface,webInterface,peerInterface)
  39.  
  40.            await webServer.init(https_enabled,webInterface,peerInterface)
  41.  
  42.  
  43.       // Code to run if we're in a worker process
  44.       } else {
  45.         var worker_id = cluster.worker.id
  46.  
  47.  
  48.             if(worker_id == 1)
  49.             {
  50.                await redisInterface.init()
  51.                await tokenInterface.init(redisInterface,web3,accountConfig,poolConfig,pool_env)
  52.  
  53.  
  54.                await peerInterface.init(web3,accountConfig,poolConfig,redisInterface,tokenInterface,pool_env) //initJSONRPCServer();
  55.                tokenInterface.update();
  56.                peerInterface.update();
  57.             }
  58.             if(worker_id >= 2)
  59.             {
  60.               await redisInterface.init()
  61.               await tokenInterface.init(redisInterface,web3,accountConfig,poolConfig,pool_env)
  62.               await peerInterface.init(web3,accountConfig,poolConfig,redisInterface,tokenInterface,pool_env)    //initJSONRPCServer();
  63.               //tokenInterface.update();
  64.               peerInterface.listenForJSONRPC(8586);
  65.             }
  66.       }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement