I am asking this since I don t have the tool or time to test this right now, but the idea is bothering me. I ll answer this myself when I ll have the time to play with it.
In node.js, how does require() work? Does it keep the required function in memory? or doest it read the file anew?
Exemple:
launcher.js
var cluster = require('cluster');
if (cluster.isMaster) {
    cluster.fork();
    cluster.on('exit', function () {
        cluster.fork();
    }
}
if (cluster.isWorker) {
    var self = require('self_modifying.js');
    self.start()
}
As long as self_modifying.js have a start() function which is the 'main' method, it could self-update just by modifying it s own source file, and the process.exit(0), and so restart with it new code?
 
     
    