mirror of https://github.com/BTCPrivate/z-nomp.git
Added logLevel to portal config
This commit is contained in:
parent
94c643a99f
commit
0edfbdf0e1
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"logLevel": "debug",
|
||||||
"clustering": {
|
"clustering": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"forks": "auto"
|
"forks": "auto"
|
||||||
|
|
11
init.js
11
init.js
|
@ -4,7 +4,7 @@ var cluster = require('cluster');
|
||||||
|
|
||||||
|
|
||||||
var posix = require('posix');
|
var posix = require('posix');
|
||||||
var PoolLogger = require('./libs/logutils.js');
|
var PoolLogger = require('./libs/logUtil.js');
|
||||||
var BlocknotifyListener = require('./libs/blocknotifyListener.js');
|
var BlocknotifyListener = require('./libs/blocknotifyListener.js');
|
||||||
var WorkerListener = require('./libs/workerListener.js');
|
var WorkerListener = require('./libs/workerListener.js');
|
||||||
var PoolWorker = require('./libs/poolWorker.js');
|
var PoolWorker = require('./libs/poolWorker.js');
|
||||||
|
@ -14,15 +14,11 @@ var Website = require('./libs/website.js');
|
||||||
JSON.minify = JSON.minify || require("node-json-minify");
|
JSON.minify = JSON.minify || require("node-json-minify");
|
||||||
|
|
||||||
|
|
||||||
|
var portalConfig = JSON.parse(JSON.minify(fs.readFileSync("config.json", {encoding: 'utf8'})));
|
||||||
|
|
||||||
|
|
||||||
var loggerInstance = new PoolLogger({
|
var loggerInstance = new PoolLogger({
|
||||||
'default': true,
|
logLevel: portalConfig.logLevel
|
||||||
'keys': {
|
|
||||||
//'client' : 'warning',
|
|
||||||
'system' : true,
|
|
||||||
'submitblock' : true
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var logDebug = loggerInstance.logDebug;
|
var logDebug = loggerInstance.logDebug;
|
||||||
|
@ -174,7 +170,6 @@ var startWebsite = function(portalConfig, poolConfigs){
|
||||||
|
|
||||||
|
|
||||||
(function init(){
|
(function init(){
|
||||||
var portalConfig = JSON.parse(JSON.minify(fs.readFileSync("config.json", {encoding: 'utf8'})));
|
|
||||||
|
|
||||||
var poolConfigs = buildPoolConfigs();
|
var poolConfigs = buildPoolConfigs();
|
||||||
|
|
||||||
|
|
24
libs/api.js
24
libs/api.js
|
@ -1,18 +1,14 @@
|
||||||
var express = require('express');
|
|
||||||
var os = require('os');
|
var os = require('os');
|
||||||
var app = express();
|
|
||||||
|
|
||||||
app.get('/getstatus', function (req, res) {
|
|
||||||
res.send({
|
|
||||||
'loadavg': os.loadavg(),
|
|
||||||
'freemem': os.freemem()
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = function(logger, poolConfigs){
|
||||||
start: function () {
|
|
||||||
app.listen(9000);
|
//Every 10 minutes clear out old hashrate stat data from redis
|
||||||
}
|
setInterval(function(){
|
||||||
}
|
var tenMinutesAgo = (Date.now() / 1000 | 0) - (60 * 10);
|
||||||
|
connection.zremrangebyscore([coin + '_hashrate', '-inf', tenMinutesAgo]);
|
||||||
|
}, 10 * 60 * 1000);
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
|
@ -39,35 +39,26 @@ var getSeverityColor = function(severity) {
|
||||||
|
|
||||||
var PoolLogger = function (configuration) {
|
var PoolLogger = function (configuration) {
|
||||||
|
|
||||||
|
var logLevelInt = severityToInt(configuration.logLevel);
|
||||||
|
|
||||||
// privates
|
// privates
|
||||||
var shouldLog = function(key, severity) {
|
var shouldLog = function(key, severity) {
|
||||||
var keyValue = configuration.keys[key];
|
var severity = severityToInt(severity);
|
||||||
if (typeof(keyValue) === 'undefined') {
|
return severity >= logLevelInt;
|
||||||
keyValue = configuration.default;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof(keyValue) === 'boolean') {
|
|
||||||
return keyValue;
|
|
||||||
} else if (typeof(keyValue) === 'string') {
|
|
||||||
return severityToInt(severity) >= severityToInt(keyValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var log = function(severity, key, poolName, text) {
|
var log = function(severity, key, poolName, text) {
|
||||||
if ( ! shouldLog(key, severity) ) {
|
if (!shouldLog(key, severity))
|
||||||
// if this tag is set to not be logged or the default value is false then drop it!
|
|
||||||
//console.log(key+"DROPPED "+text + 'SEV' + severity);
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
|
||||||
var desc = poolName ? '[' + poolName + '] ' : '';
|
var desc = poolName ? '[' + poolName + '] ' : '';
|
||||||
console.log(
|
console.log(
|
||||||
'\u001b['+getSeverityColor(severity)+'m' +
|
'\u001b[' + getSeverityColor(severity) + 'm' +
|
||||||
dateFormat(new Date(), 'yyyy-mm-dd HH:mm:ss') +
|
dateFormat(new Date(), 'yyyy-mm-dd HH:MM:ss') +
|
||||||
" ["+key+"]" + '\u001b[39m: ' + "\t" +
|
" [" + key + "]" + '\u001b[39m: ' + "\t" +
|
||||||
desc +
|
desc + text
|
||||||
text);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
// public
|
// public
|
||||||
|
|
|
@ -189,7 +189,7 @@ function SetupForPool(logger, poolOptions){
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
var poolTotalRewards = rounds.reduce(function(p, c){
|
var poolTotalRewards = rounds.reduce(function(p, c){
|
||||||
return p + c.amount;
|
return p + c.amount * c.magnitude;
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
console.log(workerRewards);
|
console.log(workerRewards);
|
||||||
|
|
|
@ -44,12 +44,6 @@ module.exports = function(logger, poolConfig){
|
||||||
connect();
|
connect();
|
||||||
|
|
||||||
|
|
||||||
//Every 10 minutes clear out old hashrate stat data from redis
|
|
||||||
setInterval(function(){
|
|
||||||
var tenMinutesAgo = (Date.now() / 1000 | 0) - (60 * 10);
|
|
||||||
connection.zremrangebyscore([coin + '_hashrate', '-inf', tenMinutesAgo]);
|
|
||||||
}, 10 * 60 * 1000);
|
|
||||||
|
|
||||||
|
|
||||||
this.handleShare = function(isValidShare, isValidBlock, shareData){
|
this.handleShare = function(isValidShare, isValidBlock, shareData){
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ var dot = require('dot');
|
||||||
var express = require('express');
|
var express = require('express');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = function(logger){
|
module.exports = function(logger){
|
||||||
|
|
||||||
var portalConfig = JSON.parse(process.env.portalConfig);
|
var portalConfig = JSON.parse(process.env.portalConfig);
|
||||||
|
|
Loading…
Reference in New Issue