Skip to content

Instantly share code, notes, and snippets.

@Soontao
Last active February 25, 2021 09:20
Show Gist options
  • Save Soontao/8e63daa8cae5d03af1ebd182c143115b to your computer and use it in GitHub Desktop.
Save Soontao/8e63daa8cae5d03af1ebd182c143115b to your computer and use it in GitHub Desktop.
// main.js
const cluster = require('cluster')
if (cluster.isMaster) {
console.log("starting...");
for (var i = 0; i < 4; i++) {
cluster.fork();
}
cluster.on('listening', worker => {
console.log(`process ${worker.process.pid}: started`);
});
cluster.on('exit', worker => {
console.log(`process ${worker.process.pid}: restarting`);
setTimeout(function () { cluster.fork(); }, 0);
});
} else {
const cds = require("@sap/cds/bin/cds");
cds.exec("run")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment