Skip to content

Instantly share code, notes, and snippets.

@devarajchidambaram
Created February 1, 2018 13:16
Show Gist options
  • Save devarajchidambaram/5a196ccda2634f872697f0e3a6b1d597 to your computer and use it in GitHub Desktop.
Save devarajchidambaram/5a196ccda2634f872697f0e3a6b1d597 to your computer and use it in GitHub Desktop.
To gently reload the config in nodejs
//https://www.npmjs.com/package/recluster
var recluster = require('recluster'),
path = require('path');
var cluster = recluster(path.join(__dirname, 'server.js'),{workers : 2});
cluster.run();
process.on('SIGUSR2', function() {
console.log('Got SIGUSR2, reloading cluster...');
cluster.reload();
});
console.log("spawned cluster, kill -s SIGUSR2", process.pid, "to reload");
//Use this command to kill and reload the nodejs cluster
//[root@linux90 ~]# kill -s SIGUSR2 2091
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment