Permalink
Browse files

Added cmdline switches: -v to force vm.createContext , -w for webwork…

…er-threads (which is default)
  • Loading branch information...
1 parent f6b621f commit ca2fc7f3758583aa7816f3a3b23c110ff491a03f abiank committed with ale Dec 25, 2012
Showing with 12 additions and 3 deletions.
  1. +12 −3 sc.js
View
15 sc.js
@@ -1,15 +1,24 @@
(function(){
- var vm, fs, path, bootSC, Worker, e;
+ var vm, fs, path, bootSC, Worker, e, using, wt;
vm = require('vm');
fs = require('fs');
+ sys = require('sys'); // for debugging, pls remove
+ argv = require('optimist').argv;
path = require('path');
bootSC = fs.readFileSync(path.dirname(fs.realpathSync(__filename)) + "/SocialCalcModule.js", 'utf8');
global.SC == null && (global.SC = {});
Worker = (function(){
try {
- return require('webworker-threads').Worker;
+ wt = require('webworker-threads').Worker;
} catch (e$) {
- e = e$;
+ wt=null;
+ }
+ if (wt!=null && argv.v != true) {
+ console.log("starting backend using webworker-threads");
+ return wt;
+ } else {
+ //e = e$;
+ console.log("starting backend using vm.CreateContext");
return (function(){
var prototype = constructor.prototype;
function constructor(code){

0 comments on commit ca2fc7f

Please sign in to comment.