Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[dist] bump first version

  • Loading branch information...
commit 2efb9bfda8f601820806607646839b403850439b 1 parent 28642fc
@alejandro alejandro authored
Showing with 15 additions and 14 deletions.
  1. +14 −13 lib/watcher.js
  2. +1 −1  package.json
View
27 lib/watcher.js
@@ -26,6 +26,14 @@ var Watcher = function (cfg) {
Host: "www.nodester.com"
}
};
+ this.codes= function(){
+ var code = {
+ N10:'Quota Exceeded :: Disk Space'
+ , N11:'Quota Exceeded :: Memory abuse'
+ , N12:'Audit by Master :: Kill signal inmminent'
+ }
+ return code;
+ };
console.log('App in audit mode by Watcher...')
events.EventEmitter.call(this);
};
@@ -47,7 +55,7 @@ Watcher.prototype.emitter = function(options){
var memory = process.memoryUsage().rss;
if (options.maxMemory>=memory && kue) {
kue = false
- kill('You reached '+options.maxMemory+'Mbs',101);
+ kill('You reached '+options.maxMemory+'Mbs','N11');
}
}
if (options.checkSpace){
@@ -61,7 +69,7 @@ Watcher.prototype.emitter = function(options){
var totalSize =eval(size.join('+'));
if (totalSize>=process.maxSpace && kue){
kue = false
- kill('There is no space left in for this app, max allowed: '+(options.sizeSpace/1024),911)
+ kill('There is no space left in for this app, max allowed: '+(options.sizeSpace)+'Mbs','N10')
}
}
});
@@ -70,7 +78,10 @@ Watcher.prototype.emitter = function(options){
function kill (msg,code) {
console.log('We detect and abuse of memory in your app, process dieing')
console.log('process error: ' + code)
- console.log('app emiting restart signal && dieing...')
+ var verb = 'stop'
+ if (code=='N11') verb = 'restart'
+ console.log(msg)
+ console.log('app emiting ' +verb+' signal && dieing...')
endPoint.body = {
PID : process.pid,
execPath : process.cwd(),
@@ -89,15 +100,5 @@ Watcher.prototype.emitter = function(options){
setInterval(smash, options.interval);
}
-Object.defineProperty(Watcher, 'codes', {
- get: function(){
- var code = {
- 911:'Quota Exceeded :: Disk Space'
- , 101:'Quota Exceeded :: Memory abuse'
- , 102:'Audit by Master :: Kill signal inmminent'
- }
- return code;
- }
-})
module.exports = Watcher;
View
2  package.json
@@ -1,5 +1,5 @@
{
- "name" : "watcher",
+ "name" : "node-watcher",
"version" : "0.0.1",
"description":"Watcher by nodester :: is a module to manage|limit resources in a shared environment",
"author" : "Alejandro Morales",

0 comments on commit 2efb9bf

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