getTrafficData(sourceOptions, selectorOptions, function (err, time) {
		if(err) {
			sys.debug("Error: " + err);
		}
		else{
			outputTrafficData(time);
		}
	});
Example #2
0
 watchItems.forEach(function (watchItem) {
   if (!watchItem.match(/^\/.*/)) { // watch is not an absolute path
     // convert watch item to absolute path
     watchItem = process.cwd() + '/' + watchItem;
   }
   sys.debug("Watching directory '" + watchItem + "' for changes.");
   findAllWatchFiles(watchItem, watchGivenFile, excludes);
 });
    stream.addListener("connect", function () {
        if (exports.debugMode)
            sys.debug("[CONNECT]");

        stream.setNoDelay();
        stream.setTimeout(0);

        client.reconnectionAttempts = 0;
        client.reconnectionDelay = 500;
        if (client.reconnectionTimer) {
            clearTimeout(client.reconnectionTimer);
            client.reconnectionTimer = null;
        }

        var eventName = client.connectionsMade == 0 
                      ? 'connected' 
                      : 'reconnected';

        client.connectionsMade++;
        client.expectingClose = false;

        // If this a reconnection and there were commands submitted, then they
        // are gone!  We cannot say with any confidence which were processed by
        // Redis; perhaps some were processed but we never got the reply, or
        // perhaps all were processed but Redis is configured with less than
        // 100% durable writes, etc.  
        //
        // We punt to the user by calling their callback with an I/O error.
        // However, we provide enough information to allow the user to retry
        // the interrupted operation.  We are certainly not retrying anything
        // for them as it is too dangerous and application-specific.

        if (client.connectionsMade > 1 && client.originalCommands.length > 0) {
            if (exports.debug) {
                sys.debug("[RECONNECTION] some commands orphaned (" + 
                    client.originalCommands.length + "). notifying...");
            }

            client.callbackOrphanedCommandsWithError();
        }
        
        client.originalCommands = [];
        client.flushQueuedCommands();

        client.emit(eventName, client);
    });
Example #4
0
 watchItems.forEach(function (watchItem) {
   if(!watchItem.match(/^\/.*/)) { // watch is not an absolute path
     // convert watch item to absolute path
     watchItem = process.cwd() + '/' + watchItem;
   }
   sys.debug("WatchItem: " + watchItem);
   findAllJsFiles(watchItem, watchGivenFile);
 });
Example #5
0
 p.stderr.addListener('data', function (data) {
     if (/^execvp\(\)/.test(data.slice(0,data.length))) {
         nodelog(null, 'Failed to start R child process. Exiting R-Node');
         rServerProcess = null;
         process.exit(-1);
     }
     SYS.debug('R stderr: ' + data);
 });
Example #6
0
app.post('/event', function(req, res) {
   sys.debug('flickr-event!!!');
    fs.writeFileSync('events', "" + eventCount);
    eventCount++;
//        sys.debug("events:" + fs.readFileSync('events'));
    res.writeHead(200);
    res.end();
});
Example #7
0
        function notFound() {

            res.writeHead(404, { });
            res.end();

            if (DEBUG) {sys.debug(req.method + " " + req.url + " NOT FOUND");}

        }
	getHTMLBody(sourceOptions, function (err, body){
		if(err){
			sys.debug("Error: " + err);
		}
		else{
			parseBodyForTime(body, selectorOptions, callback);
		}
	})
Example #9
0
 response.addListener('end', function () {
   var bodyObj = JSON.parse(responseBody);
   if (bodyObj.responseStatus === 200) {
     callback(bodyObj.responseData.translatedText);
   } else {
     sys.debug("Translate API call failed");
   }
 });
Example #10
0
			worker.writeJob(job, function (err, result, aborted) {
				if (!(self.pullWorker(workerSelf, self.activeWorkers) || self.pullWorker(workerSelf, self.idleWorkers)))
					sys.debug("Failed to pull worker");
				job.callback(err, result);
				if (!aborted)
					self.idleWorkers.push(workerSelf);
				self.runJobs();
			}, this.options.jobTimeout); //TODO: job-level timeouts
Example #11
0
function requestMgr (req, resp) {
    if (req.url.beginsWith('/__login')) {
        login (req, resp);
        return;
    }

    if (req.url.beginsWith('/__authmethods')) {
        resp.writeHeader(200, { "Content-Type": "text/plain" });
        resp.write(AUTH.clientMechanism);
        resp.end();
        return;
    }
    
    if (req.url.beginsWith('/__capabilities')) {
        resp.writeHeader(200, { "Content-Type": "text/plain" });
        resp.write(JSON.stringify (capabilities));
        resp.end();
        return;
    }

    cleanOutSessions();

    // URLs that require the Authenticator to ok access:
    var requiredAuth = false;
    restrictedUrls.forEach (function (p) {
        if (req.url.search (p) >= 0) {
            requiredAuth = true;
        }
    });

    // Get sid 
    var url = URL.parse (req.url, true);
    var sid = (url.query && url.query.sid) ? url.query.sid : null;

    if (requiredAuth) {
        if (!sid) {
            SYS.debug ('requestMgr: No sid. cannot continue.');
            resp.writeHeader(403, { "Content-Type": "text/plain" });
            resp.end();
            return;
        }

        Authenticator.checkRequest (req, sid, function (ok) {
            if (ok) {
                authorizedRequestMgr (req, resp, sid);
                sessions[sid].lastAccessTime = new Date();
            } else {
                if (sid) 
                    delete sessions[sid];

                resp.writeHeader(403, { "Content-Type": "text/plain" });
                resp.end();
            }
        });
    } else {
        authorizedRequestMgr (req, resp, sid);
    }
}
Example #12
0
 var oncreate = function (rc, path, error)  {
     if (rc != 0) sys.debug ("node create error: " + rc + ", path=" + path);
     if (++counter >= N) {
         postMessage({ done : counter });
         process.nextTick(function () {
             zk.close ();
         });
     }
 };
Example #13
0
    message.addListener('data', function (d) {        
      if (d) {

        try {
          data = eval("("+d+")");
          repository = data['repository'];
          repository = repository.replace(/\.git$/, '');
          try {            
            update_or_create(repository,config.rsp['projects_dir'],config.rsp['git_user'],config.rsp['git_server']);
          } catch(e){
            sys.debug("[ERROR] Cant Create or Update: " + e);
          }

        } catch(e){
          sys.debug("[ERROR] Failed to decode json object");
        }
      }      
    });
Example #14
0
	this.client.addListener('pubsub:event', function(from, node, event_, stanza) {
		if(from == pubsub.to) {
			sys.debug('a pubsub event'.yellow);
			var cb = pubsub._eventCallback[node];
			if(cb != null) {
				cb.call(pubsub, event_, stanza);
			}
		}
	});
Example #15
0
 logger: function(msg, level) {
     if (level == grappler.LOG.INFO)
         msg = 'INFO: ' + msg;
     else if (level == grappler.LOG.WARN)
         msg = 'WARN: ' + msg;
     else
         msg = 'ERROR: ' + msg;
     sys.debug(msg);
 }
	var handler = new htmlparser.DefaultHandler(function(err, htmlText) {
  if (err) {
          sys.debug("Error: " + err);
      } else {

          var elem = select(htmlText, options.selector);
        	callback(err, elem[0].children[3].children[2].children[5].children[0].children[0].data);            
      }
  });
Example #17
0
    stream.addListener("end", function () {
        if (exports.debugMode && client.originalCommands.length > 0) {
            sys.debug("Connection to redis closed with " + 
                      client.originalCommands.length + 
                      " commands pending replies that will never arrive!");
        }

        stream.end();
    });
Example #18
0
 this.process.addListener('exit', function (code) {
     sys.debug('DEVSERVER: Child process exited: ' + code);
     this.process = null;
     if (that.restarting) {
         that.restarting = true;
         that.unwatchFiles();
         that.start();
     }
 });
Example #19
0
function onRequest(request,response) {
  var postData = '';
  var headers = request.headers;
  console.log("Headers :::" + headers);
    if(request.method =='GET') {
	sys.debug("in get");
        var getPathName = url.parse(request.url).pathname;
        sys.debug("GET PATH NAME" + getPathName);
	//var id = getPathName.split("=");
        //console.log("GET ID :::" + id[1]);
	//var sendData = getValuesFromDB(id[1]);
	getValuesFromMysqlDB();
        //sys.debug("From Get" + sendData);
        response.writeHead(200,{"Context-type":"text/html"});
        //response.write(JSON.stringify(sendData));
        response.end();
	}
}
 session.socket.addListener('error', function(){
   sys.debug('Server Socket Error');
   if (session.client){
     session.client.quit();
     delete(session.client);
   }
   session.socket.end();
   delete(session.socket);
 });
Example #21
0
    parser.onPartEnd = function(part) {
        if (outname) val = outname; // TODO new FileBlob(outname);
        if (!val) val = "";
        sys.debug("end part, key: '"+ key +"' value: '"+ val.slice(0, 25) +"' blob:"+ !!outname);

        if (key == "value") key = ""; // value is ourselves...
        target.set(key, val);

        // reset state
        key = null;
        val = null;
        if (outstream) {
            sys.debug("closing blob file: "+ outname);
            if (outstream.writeable) outstream.end();
            outstream = null;
            outname = null;
        }
    }
Example #22
0
 var workerFromCode = function(workerCode) {
   try {
     var sandbox = {tempFun: null};
     vm.runInNewContext('tempFun = ' + workerCode, sandbox, 'worker_instance.js');
     return sandbox.tempFun;
   } catch(e) {
     sys.debug(e);
   }
 };
Example #23
0
    message.addListener('data', function (d) {        
      if (d) {
        try {
          data = eval("("+d+")");
          var user = data['user'];
          var key = data['key'];

          try {
            add_user_key(user, key, connection.config);
          } catch(e){
            sys.debug("[ERROR] Can't add user key: " + e);
          }

        } catch(e){
          sys.debug("[ERROR] Failed to decode json object");
        }
      }      
    });
socket.on('connection', function (client) {
  sys.debug('Got websocket connection');

  client.on('message', function (msg) {
    sys.debug('Got message from client: ' + msg);
  });

  socket.broadcast('from server');
});
Example #25
0
			}).addListener("data", function (data) {
			sys.debug("hi" + data);
		// handle incoming data
		// send data to ALL clients whenever ANY client send up data
		for (var i = 0 ; i < clients.length ; i ++ ) {
			clients[i].write(data);
		}

    }).addListener("close", function () {
function upload_complete(res) {
    sys.debug("Request complete");
    // Render response
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.write("Thanks for playing!");
    res.end();

    sys.puts("\n=> Done");
}
Example #27
0
 function CreateTree(currentTree, numval, lengths, show) {
     var i;
     /* Create the Huffman decode tree/table */
     //document.write("<br>createtree<br>");
     if (debug)
       sys.debug("currentTree " + currentTree + " numval " + numval + " lengths " + lengths + " show " + show);
     Places = currentTree;
     treepos=0;
     flens = lengths;
     fmax  = numval;
     for (i=0;i<17;i++)
         fpos[i] = 0;
     len = 0;
     if(Rec()) {
         //fprintf(stderr, "invalid huffman tree\n");
         if (debug)
           sys.debug("invalid huffman tree");
         return -1;
     }
     if (debug){
       sys.debug("Tree: " + Places.length);
     	for (var a=0;a<32;a++){
     	  sys.debug("Places[" + a + "].b0=" + Places[a].b0);
     	  sys.debug("Places[" + a + "].b1=" + Places[a].b1);
     	}
     }
 
     /*if(show) {
         var tmp;
         for(tmp=currentTree;tmp<Places;tmp++) {
             fprintf(stdout, "0x%03x  0x%03x (0x%04x)",tmp-currentTree, tmp->jump?tmp->jump-currentTree:0,(tmp->jump?tmp->jump-currentTree:0)*6+0xcf0);
             if(!(tmp.b0 & 0x8000)) {
                 //fprintf(stdout, "  0x%03x (%c)", tmp->b0,(tmp->b0<256 && isprint(tmp->b0))?tmp->b0:'�');
             }
             if(!(tmp.b1 & 0x8000)) {
                 if((tmp.b0 & 0x8000))
                     fprintf(stdout, "           ");
                 fprintf(stdout, "  0x%03x (%c)", tmp->b1,(tmp->b1<256 && isprint(tmp->b1))?tmp->b1:'�');
             }
             fprintf(stdout, "\n");
         }
     }*/
     return 0;
 };
Example #28
0
      http.createServer (function (request, response) {
         var handler = self._not_found;
         var uri = url.parse (request.url, true);
         var args = [];
         var ix;
         var route;
         
         //request.headers['accept'] = 'application/json';

         request.uri = {
            path: uri.pathname || '/',
            params: uri.query || {},
            search: uri.search || '',
         };
         
         request.proxy = {
            path: uri.pathname || '/',
            params: uri.query || {},
         };
         
         for (ix = 0; ix < self._routes.length; ix++) {
            route = self._routes[ix];
            if (route.method === request.method && route.path.test (request.uri.path)) {
               args = route.path.exec (request.uri.path);
               handler = route.handler;
               break;
            }
         }
         
         response.reply = function (code, data) {
            var content = JSON.stringify (data);
            response.sendHeader (code, {
               'Content-Type': 'application/json',
               'Content-Length': content.length,
            });
            
            response.write (content);
            response.close ();
         };
         
         try {
            handler.apply ({
                  request: request,
                  response: response,
                  proxy: self._proxy,
               },
               args.slice (1));
         }
         catch (e) {
            response.reply (500, {
                error: e.name,
                reason: e.message,
            });
            sys.debug (e.stack);
         }
      }).listen (this._port, this._host);
Example #29
0
Room.prototype.presence = function() {
	sys.debug(('presence: ' + this.room)[this.client.color]);
	this.client.xmpp.send(new xmpp.Element('presence', {
			to: this.to
		})
		.c('priority').t("5").up()
		.c('x', {xmlns:"http://jabber.org/protocol/muc"})
		.tree()
	);
};
Example #30
0
HTML5.debug = function() {
	section = arguments[0];
	if(debugFlags[section] || debugFlags[section.split('.')[0]]) {
		var str = [];
		for(var i in arguments) {
			str.push(sys.inspect(arguments[i]))
		}
		sys.debug(str.join(' '))
	}
}