I have a nodeJS command line script which interacts with a website using phantomJS via casperJS/spookyJS. A redirect event is stopping my process from working correctly. How would I respond to the redirect, spawn a new process and kill the process which has been redirected?
e.g:
spooky.on('navigation.requested', function(url, navigationType, navigationLocked, isMainFrame){
if (url.toString().match(/(http:\/\/url(.|\n)to(.|\n)match\/client\/authentication\/login)/i)) {
utils.log('redirect happened');
//get my own process id, launch a new process, get that id.
//kill this id?
}
});
How would I:
- Get the process Id of the currently running node process (the one running the above code - process A)?
- Spawn a new node process (process B) which would be independent of process A
- Kill Process A
Process B should continue to run even when process A has terminated. Would I need a third node process (C) to manage process A and B?