+ move s.processReady
merge-requests/63/head
Moe 2018-09-28 20:06:32 -07:00
parent 3efbfae9bb
commit 91f5451c6e
2 changed files with 12 additions and 6 deletions

View File

@ -18,11 +18,7 @@ module.exports = function(s,config,lang,io){
io.sockets.emit('ping',{beat:1});
}
s.beat();
s.processReady = function(){
s.systemLog(lang.startUpText5)
process.send('ready')
}
s.cpuUsage=function(e){
s.cpuUsage = function(e){
k={}
switch(s.platform){
case'win32':
@ -34,6 +30,9 @@ module.exports = function(s,config,lang,io){
case'linux':
k.cmd='LANG=C top -b -n 2 | grep "^'+config.cpuUsageMarker+'" | awk \'{print $2}\' | tail -n1';
break;
case'freebsd':
k.cmd='vmstat 1 2 | tail -1 | awk \'{print $17}\''
break;
}
if(config.customCpuCommand){
exec(config.customCpuCommand,{encoding:'utf8',detached: true},function(err,d){
@ -53,7 +52,7 @@ module.exports = function(s,config,lang,io){
e(0)
}
}
s.ramUsage=function(e){
s.ramUsage = function(e){
k={}
switch(s.platform){
case'win32':
@ -62,6 +61,9 @@ module.exports = function(s,config,lang,io){
case'darwin':
k.cmd = "vm_stat | awk '/^Pages free: /{f=substr($3,1,length($3)-1)} /^Pages active: /{a=substr($3,1,length($3-1))} /^Pages inactive: /{i=substr($3,1,length($3-1))} /^Pages speculative: /{s=substr($3,1,length($3-1))} /^Pages wired down: /{w=substr($4,1,length($4-1))} /^Pages occupied by compressor: /{c=substr($5,1,length($5-1)); print ((a+w)/(f+a+i+w+s+c))*100;}'"
break;
case'freebsd':
k.cmd = "echo \"scale=4; $(vmstat -H | tail -1 | awk '{print $5}')*1024*100/$(sysctl hw.physmem | awk '{print $2}')\" | bc"
break;
default:
k.cmd = "LANG=C free | grep Mem | awk '{print $4/$2 * 100.0}'";
break;

View File

@ -4,6 +4,10 @@ var exec = require('child_process').exec;
var execSync = require('child_process').execSync;
console.log('NODE.JS version : '+execSync("node -v"))
module.exports = function(s,config,lang,io){
s.processReady = function(){
s.systemLog(lang.startUpText5)
process.send('ready')
}
if(config.childNodes.mode !== 'child'){
//add Cloud Videos table, will remove in future
s.sqlQuery('CREATE TABLE IF NOT EXISTS `Cloud Videos` (`mid` varchar(50) NOT NULL,`ke` varchar(50) DEFAULT NULL,`href` text NOT NULL,`size` float DEFAULT NULL,`time` timestamp NULL DEFAULT NULL,`end` timestamp NULL DEFAULT NULL,`status` int(1) DEFAULT \'0\' COMMENT \'0:Complete,1:Read,2:Archive\',`details` text) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;',[],function(err){