Socket
Socket
Sign inDemoInstall

pm2

Package Overview
Dependencies
14
Maintainers
1
Versions
277
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.1 to 0.4.2

7

lib/God.js

@@ -6,5 +6,5 @@ // pm2-monitor // Code name : God

var numCPUs = require('os').cpus().length;
var usage = require('usage');
var path = p = require('path');
var cst = require('../constants.js');
var usage = require('usage');
var path = p = require('path');
var cst = require('../constants.js');

@@ -176,2 +176,3 @@ cluster.setupMaster({

God.stopProcessId = function(id, cb) {
console.log(id);
God.clusters_db[id].opts.max = 0;

@@ -178,0 +179,0 @@ process.kill(God.clusters_db[id].process.pid);

@@ -7,8 +7,8 @@ //

var http = require('http');
var os = require('os');
var http = require('http');
var os = require('os');
var Satan = require('./Satan');
var urlT = require('url');
var cst = require('../constants.js');
var p = require('path');
var urlT = require('url');
var cst = require('../constants.js');
var p = require('path');

@@ -37,3 +37,3 @@ http.createServer(function (req, res) {

};
res.write(JSON.stringify(data));

@@ -40,0 +40,0 @@ return res.end();

@@ -0,14 +1,25 @@

// pm2-htop
// Library who interacts with PM2 to display processes resources in htop way
// by Strzelewicz Alexandre
var multimeter = require('multimeter');
var os = require('os');
var bars = {};
var bars = {};
// Cst for light programs
const RATIO_T1 = Math.floor(os.totalmem() / 500);
// Cst for medium programs
const RATIO_T2 = Math.floor(os.totalmem() / 50);
// Cst for heavy programs
const RATIO_T3 = Math.floor(os.totalmem() / 5);
// Cst for heavy programs
const RATIO_T4 = Math.floor(os.totalmem());
var Monit = module.exports = {};
const RATIO = 300000000;
var Monit = module.exports = {};
Monit.init = function(processes) {
Monit.init = function(processes, debug) {
if (processes === undefined || processes[0] == null)
throw new Error('No processes passed to init');
if (processes[0].monit == null || processes[0].monit == undefined)

@@ -54,5 +65,4 @@ throw new Error('You seems to run on a Mac OS, node-usage can\'t get monitor data');

bar_cpu.percent(proc.monit.cpu);
bar_memory.ratio(proc.monit.memory,
RATIO,
bytesToSize(proc.monit.memory, 3));
Monit.drawRatio(bar_memory, proc.monit.memory);
bars[proc.pid] = {};

@@ -65,2 +75,20 @@ bars[proc.pid].memory = bar_memory;

Monit.stop = function() {
Monit.multi.charm.destroy();
};
// Draw memory bars
Monit.drawRatio = function(bar_memory, memory) {
var scale = 0;
if (memory < RATIO_T1) scale = RATIO_T1;
else if (memory < RATIO_T2) scale = RATIO_T2;
else if (memory < RATIO_T3) scale = RATIO_T3;
else scale = RATIO_T4;
bar_memory.ratio(memory,
scale,
bytesToSize(memory, 3));
};
Monit.refresh = function(dt) {

@@ -71,5 +99,4 @@ dt.forEach(function(proc, i) {

bars[proc.pid].cpu.percent(proc.monit.cpu);
bars[proc.pid].memory.ratio(proc.monit.memory,
RATIO,
bytesToSize(proc.monit.memory, 3));
Monit.drawRatio(bars[proc.pid].memory, proc.monit.memory);
}

@@ -76,0 +103,0 @@ });

@@ -87,3 +87,8 @@

},
stop : function(opts, fn) {
stopId : function(opts, fn) {
God.stopProcessId(opts.id, function(err, clu) {
fn(err, stringifyOnce(clu, undefined, 0));
});
},
stopAll : function(opts, fn) {
God.stopAll(fn);

@@ -90,0 +95,0 @@ },

{
"name": "pm2",
"preferGlobal": "true",
"version": "0.4.1",
"version": "0.4.2",
"engines" : {

@@ -6,0 +6,0 @@ "node" : ">=0.8"

@@ -9,2 +9,4 @@ ![Monit](https://github.com/unitech/pm2/raw/master/pres/pm2.png)

PM2 is mainly a production module for Linux servers.
# Installation

@@ -31,2 +33,3 @@

$ pm2 generate app // Generate a JSON process configuration
$ pm2 web // Health computer API endpoint (http://localhost:9615)
```

@@ -59,2 +62,11 @@

## pm2 health web api endpoint
PM2 can disserve an API endpoint to monitor processes and computer health (cpu usage, memory, network interfaces...)
```
pm2 web
```
# Features

@@ -61,0 +73,0 @@

@@ -10,3 +10,76 @@

Monit.should.have.property('refresh');
Monit.should.have.property('drawRatio');
Monit.should.have.property('stop');
});
var fixt1 = [{
pid : 324,
opts : {
script : 'asd'
},
monit: {
memory: 13357056,
cpu: 0
}
},{
pid : 3245,
opts : {
script : 'asd'
},
monit: {
memory: 133570560,
cpu: 0
}
},{
pid : 3247,
opts : {
script : 'asd'
},
monit: {
memory: 1335705600,
cpu: 0
}
}];
var fixt2 = [{
pid : 324,
opts : {
script : 'asd'
},
monit: {
memory: 23357096,
cpu: 0
}
},{
pid : 3245,
opts : {
script : 'asd'
},
monit: {
memory: 233570560,
cpu: 0
}
},{
pid : 3247,
opts : {
script : 'asd'
},
monit: {
memory: 2335705600,
cpu: 0
}
}];
it('should init', function() {
Monit.init(fixt1);
});
it('should refresh and handle processes with different sizes', function() {
Monit.refresh(fixt2);
});
it('should stop monitoring', function() {
Monit.stop();
});
});

@@ -21,3 +21,3 @@

done();
})
});
});

@@ -55,3 +55,4 @@ });

methods.should.have.property('list');
methods.should.have.property('stop');
methods.should.have.property('stopId');
methods.should.have.property('stopAll');
methods.should.have.property('killMe');

@@ -72,7 +73,7 @@ methods.should.have.property('daemonData');

Satan.executeRemote('prepare', {
pm_exec_path : path.resolve(process.cwd(), 'test/fixtures/echo.js'),
pm_exec_path : path.resolve(process.cwd(), 'test/fixtures/echo.js'),
pm_err_log_path : path.resolve(process.cwd(), 'test/errLog.log'),
pm_out_log_path : path.resolve(process.cwd(), 'test/outLog.log'),
pm_pid_path : path.resolve(process.cwd(), 'test/child'),
instances : 4
pm_pid_path : path.resolve(process.cwd(), 'test/child'),
instances : 4
}, function(err, procs) {

@@ -79,0 +80,0 @@ assert(err == null);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc