I tried to use vm module for node.js.
var myCode = 'MY JS CODE with setInterval or setTimeout';
var vm = require('vm');
vm.runInNewContext(myCode, {cb: cb});
It`s work great! But... How can i stop it? For example, i wanna to do
var identity = vm.runInNewContext(myCode, {cb: cb});
if (i_wanna_kill) {
vm.kill(identity);
}
I have a lot of scripts, which i can run somethimes and need to stop them. It`s somethink like daemons.. I tried to do that with vm module for node.js, but, maybe another way to run foreign scripts by node?!