I'm using Node.js to run background jobs (no frontend). I think the best way for me to run the workers is to have one file for each kind of job (like that I can easily run one worker per server).
main.js
require('scribe-js')(); // github.com/bluejamesbond/Scribe.js
process.console = console;
...
worker_*.js
require('./lib/main');
console.tag('testing').log('this is a test');
The console variable isn't passed to worker_*.js. I to set it in main.js because if the value of the variable ever changes I want to be able to change it only once (in main.js) and not in each worker_*.js file. Any idea?
I think this is not a duplicate: I know there's plenty of "how do I include a JS file in another JS file in Node.js" and the answer is usually "use var s = require('yourfile');". I think this question is a bit different.
worker_*.jsfiles I would need to writeprocess.console = globals.customConsole;instead of just having it once in mymain.jsfile. I'm trying to figure out a solution so I only define it once and it's available to all workers that includemain.js. edit: weird, one of the comments disappeared