mirror of
https://github.com/Unitech/pm2.git
synced 2026-02-01 16:57:09 +00:00
(interactor) cache some variables
This commit is contained in:
parent
c7586c18c2
commit
9d8251e772
@ -25,6 +25,14 @@ try {
|
||||
} catch(e) {
|
||||
}
|
||||
|
||||
var SERVER_META = {
|
||||
totalMem : os.totalmem(),
|
||||
hostname : os.hostname(),
|
||||
type : os.type(),
|
||||
platform : os.platform(),
|
||||
arch : os.arch()
|
||||
};
|
||||
|
||||
var Filter = {};
|
||||
|
||||
Filter.getProcessID = function(machine_name, name, id) {
|
||||
@ -75,14 +83,14 @@ Filter.status = function(processes, conf) {
|
||||
process : filter_procs,
|
||||
server : {
|
||||
loadavg : os.loadavg(),
|
||||
total_mem : os.totalmem(),
|
||||
total_mem : SERVER_META.totalMem,
|
||||
free_mem : os.freemem(),
|
||||
cpu : cpu_info,
|
||||
hostname : os.hostname(),
|
||||
hostname : SERVER_META.hostname,
|
||||
uptime : os.uptime(),
|
||||
type : os.type(),
|
||||
platform : os.platform(),
|
||||
arch : os.arch(),
|
||||
type : SERVER_META.type,
|
||||
platform : SERVER_META.platform,
|
||||
arch : SERVER_META.arch,
|
||||
user : username,
|
||||
interaction : conf.REVERSE_INTERACT,
|
||||
pm2_version : conf.PM2_VERSION,
|
||||
@ -105,7 +113,7 @@ Filter.monitoring = function(processes, conf) {
|
||||
|
||||
return {
|
||||
loadavg : os.loadavg(),
|
||||
total_mem : os.totalmem(),
|
||||
total_mem : SERVER_META.totalMem,
|
||||
free_mem : os.freemem(),
|
||||
processes : filter_procs
|
||||
};
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
/**
|
||||
* Copyright 2013 the PM2 project authors. All rights reserved.
|
||||
* Use of this source code is governed by a license that
|
||||
* can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
var fclone = require('fclone');
|
||||
|
||||
var Tools = {};
|
||||
|
||||
Tools.serialize = fclone;
|
||||
23
test/interface/filter.mocha.js
Normal file
23
test/interface/filter.mocha.js
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
var Filter = require('../../lib/Interactor/Filter.js');
|
||||
var should = require('should');
|
||||
var os = require('os');
|
||||
|
||||
describe('Filter Utility', function() {
|
||||
it('should .status works as expected', function() {
|
||||
var filtered = Filter.status([], {
|
||||
REVERSE_INTERACT : true,
|
||||
PM2_VERSION : '2.2.0'
|
||||
});
|
||||
filtered.server.should.have.properties(['loadavg', 'total_mem', 'free_mem']);
|
||||
should(filtered.server.total_mem).eql(os.totalmem());
|
||||
should(filtered.server.arch).eql(os.arch());
|
||||
});
|
||||
|
||||
it('should .monitoring works as expected', function() {
|
||||
var filtered = Filter.monitoring([], {});
|
||||
filtered.should.have.properties(['loadavg', 'total_mem', 'free_mem', 'processes']);
|
||||
filtered.total_mem.should.eql(os.totalmem());
|
||||
});
|
||||
|
||||
});
|
||||
@ -109,5 +109,7 @@ mocha --opts ./mocha.opts ./stacktrace.mocha.js
|
||||
spec "Stacktrace Utility"
|
||||
mocha --opts ./mocha.opts ./cache.mocha.js
|
||||
spec "Cache Utility"
|
||||
mocha --opts ./mocha.opts ./filter.mocha.js
|
||||
spec "Filter Utility"
|
||||
mocha --opts ./mocha.opts ./pm2.link.check.mocha.js
|
||||
spec "Transaction option enablement"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user