Skip to content

Instantly share code, notes, and snippets.

@fantasyni
Created June 5, 2014 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fantasyni/5f6454a0eb673ec66538 to your computer and use it in GitHub Desktop.
Save fantasyni/5f6454a0eb673ec66538 to your computer and use it in GitHub Desktop.
var fork = require('child_process').fork;
var spawn = require('child_process').spawn;
for (var i = 0; i < 5; i++) {
fork("watch.js");
// var ls = spawn("node", ["watch.js"]);
// ls.stdout.on('data', function(data) {
// process.stdout.write(data.toString());
// });
// ls.stderr.on('data', function(data) {
// console.log(data.toString());
// });
// ls.on('close', function(code) {
// console.log('child process exited with code ' + code);
// });
}
var myRequire = function(module) {
var modulePath = require.resolve(module);
if (require.cache[modulePath]) {
delete require.cache[modulePath];
}
return require(module)
}
var fs = require('fs');
// watch files directory file
var p = __dirname + "/files/vvv.js";
fs.watch("files", function(event, filename) {
var r = myRequire(p);
console.log(process.pid);
console.log(r);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment