Um.. I write a module for auto reload module without shutdown the server. It can be used like this:
var reload = require('auto-reload');
var data = reload('./data', 3000); // reload every 3 secs
// print data every sec
setInterval(function() {
console.log(data);
}, 1000);
And if you update the file data.json or .js, the var data can be auto reloaded.
I did this by;
delete require.cache[whole];
var update = require(whole);
// clone new module data to old reference
clone(module, update);
I just want to discuss the possible negative effect or problem, and how to fix or improve.
Thanks a lot if you reply.