ProtonCluster.startByCPUS(() => {
console.log("Process");
});
ProtonCluster.start(8, () => {
console.log("Process");
});
ProtonCluster.startByCPUS(() => {
new ProtonApplication()
.addRouter(new TasksRouter())
.start();
});
Events behaviors should be configured before start clusters.
ProtonCluster.onOnline(worker => {
console.log(`I am Online Event`);
});
ProtonCluster.onExit(worker => {
console.log(`I am Exit Event`);
});
ProtonCluster.onDisconnect(worker => {
console.log(`I am Disconnect Event`);
});
ProtonCluster.onMessage(worker => {
console.log(`I am Message Event`);
});
ProtonCluster.startByCPUS(() => {
console.log("Test");
});
You can access native Node.js cluster instance
let cluster = ProtonCluster.cluster;
cluster.on("online", worker => {
console.log(`Cluster ${worker.process.pid} online`);
});