Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[dist] bump first version

  • Loading branch information...
commit 2efb9bfda8f601820806607646839b403850439b 1 parent 28642fc
Alejandro Morales alejandro authored

Showing 2 changed files with 15 additions and 14 deletions. Show diff stats Hide diff stats

  1. +14 13 lib/watcher.js
  2. +1 1  package.json
27 lib/watcher.js
@@ -26,6 +26,14 @@ var Watcher = function (cfg) {
26 26 Host: "www.nodester.com"
27 27 }
28 28 };
  29 + this.codes= function(){
  30 + var code = {
  31 + N10:'Quota Exceeded :: Disk Space'
  32 + , N11:'Quota Exceeded :: Memory abuse'
  33 + , N12:'Audit by Master :: Kill signal inmminent'
  34 + }
  35 + return code;
  36 + };
29 37 console.log('App in audit mode by Watcher...')
30 38 events.EventEmitter.call(this);
31 39 };
@@ -47,7 +55,7 @@ Watcher.prototype.emitter = function(options){
47 55 var memory = process.memoryUsage().rss;
48 56 if (options.maxMemory>=memory && kue) {
49 57 kue = false
50   - kill('You reached '+options.maxMemory+'Mbs',101);
  58 + kill('You reached '+options.maxMemory+'Mbs','N11');
51 59 }
52 60 }
53 61 if (options.checkSpace){
@@ -61,7 +69,7 @@ Watcher.prototype.emitter = function(options){
61 69 var totalSize =eval(size.join('+'));
62 70 if (totalSize>=process.maxSpace && kue){
63 71 kue = false
64   - kill('There is no space left in for this app, max allowed: '+(options.sizeSpace/1024),911)
  72 + kill('There is no space left in for this app, max allowed: '+(options.sizeSpace)+'Mbs','N10')
65 73 }
66 74 }
67 75 });
@@ -70,7 +78,10 @@ Watcher.prototype.emitter = function(options){
70 78 function kill (msg,code) {
71 79 console.log('We detect and abuse of memory in your app, process dieing')
72 80 console.log('process error: ' + code)
73   - console.log('app emiting restart signal && dieing...')
  81 + var verb = 'stop'
  82 + if (code=='N11') verb = 'restart'
  83 + console.log(msg)
  84 + console.log('app emiting ' +verb+' signal && dieing...')
74 85 endPoint.body = {
75 86 PID : process.pid,
76 87 execPath : process.cwd(),
@@ -89,15 +100,5 @@ Watcher.prototype.emitter = function(options){
89 100 setInterval(smash, options.interval);
90 101 }
91 102
92   -Object.defineProperty(Watcher, 'codes', {
93   - get: function(){
94   - var code = {
95   - 911:'Quota Exceeded :: Disk Space'
96   - , 101:'Quota Exceeded :: Memory abuse'
97   - , 102:'Audit by Master :: Kill signal inmminent'
98   - }
99   - return code;
100   - }
101   -})
102 103
103 104 module.exports = Watcher;
2  package.json
... ... @@ -1,5 +1,5 @@
1 1 {
2   - "name" : "watcher",
  2 + "name" : "node-watcher",
3 3 "version" : "0.0.1",
4 4 "description":"Watcher by nodester :: is a module to manage|limit resources in a shared environment",
5 5 "author" : "Alejandro Morales",

0 comments on commit 2efb9bf

Please sign in to comment.
Something went wrong with that request. Please try again.