Permalink
Browse files

[master] Fixed EventEmmitters bug

  • Loading branch information...
1 parent 0487e4b commit ed43a5e4fd54e48171a27feb9d152c4135fc739c @alejandro alejandro committed Mar 23, 2012
Showing with 13 additions and 8 deletions.
  1. +7 −2 examples/child.js
  2. +6 −6 lib/watcher.js
View
@@ -1,5 +1,10 @@
-require('watcher')({
- maxMemory:25000 //25mb
+var watcher = (new (require('../lib/watcher'))({
+ host:'localhost'
+}))
+
+
+watcher.emitter({
+ maxMemory:25 //25mb
})
View
@@ -8,7 +8,7 @@
*/
var exec = require('child_process').exec;
var bolt = require('bolt');
-var ee = require('events').EventEmmiter;
+var events = require("events");
var utils = require('util');
var Watcher = function (cfg) {
@@ -20,10 +20,10 @@ var Watcher = function (cfg) {
auth: cfg.auth || '',
silent:true
});
- return this;
+ events.EventEmitter.call(this);
};
+utils.inherits(Watcher, events.EventEmitter);
-utils.inherits(Watcher,ee);
Watcher.prototype.emitter = function(options){
var mesh = this.mesh;
@@ -38,7 +38,7 @@ Watcher.prototype.emitter = function(options){
function smash() {
if (options.maxMemory != -1) {
var memory = process.memoryUsage().rss;
- if (memory >= options.maxMemory) {
+ if (options.maxMemory>=memory) {
kill('You reached '+options.maxMemory+'Mbs',101);
}
}
@@ -50,7 +50,7 @@ Watcher.prototype.emitter = function(options){
return !isNaN(parseInt(mem)) ? parseInt(mem):0;
});
// Evil eval is evil, too lazy right now to make the map|forEach|filter function
- var totalSize =eval(size.join('+')));
+ var totalSize =eval(size.join('+'));
if (totalSize>=options.sizeSpace){
kill('There is no space left in for this app, max allowed: '+(options.sizeSpace/1024),911)
}
@@ -97,4 +97,4 @@ Object.defineProperty(Watcher, 'codes', {
}
})
-module.exports = watcher;
+module.exports = Watcher;

0 comments on commit ed43a5e

Please sign in to comment.