You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

37 lines
838 B

/*!
* accounts/index-cluster.js
* Copyright © 2019 – Katana Cryptographic Ltd. All Rights Reserved.
*/
'use strict'
const os = require('os')
const cluster = require('cluster')
const Logger = require('../lib/logger')
/**
* Launch a cluster of Samourai API
*/
const nbCPUS = os.cpus()
if (cluster.isMaster) {
nbCPUS.forEach(function() {
cluster.fork()
})
cluster.on('listening', function(worker) {
Logger.info(`API : Cluster ${worker.process.pid} connected`)
})
cluster.on('disconnect', function(worker) {
Logger.info(`API : Cluster ${worker.process.pid} disconnected`)
})
cluster.on('exit', function(worker) {
Logger.info(`API : Cluster ${worker.process.pid} is dead`)
// Ensuring a new cluster will start if an old one dies
cluster.fork()
})
} else {
require('./index.js')
}