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": {
|
||||
"enabled": true,
|
||||
"forks": "auto"
|
||||
|
|
11
init.js
11
init.js
|
@ -4,7 +4,7 @@ var cluster = require('cluster');
|
|||
|
||||
|
||||
var posix = require('posix');
|
||||
var PoolLogger = require('./libs/logutils.js');
|
||||
var PoolLogger = require('./libs/logUtil.js');
|
||||
var BlocknotifyListener = require('./libs/blocknotifyListener.js');
|
||||
var WorkerListener = require('./libs/workerListener.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");
|
||||
|
||||
|
||||
var portalConfig = JSON.parse(JSON.minify(fs.readFileSync("config.json", {encoding: 'utf8'})));
|
||||
|
||||
|
||||
var loggerInstance = new PoolLogger({
|
||||
'default': true,
|
||||
'keys': {
|
||||
//'client' : 'warning',
|
||||
'system' : true,
|
||||
'submitblock' : true
|
||||
}
|
||||
logLevel: portalConfig.logLevel
|
||||
});
|
||||
|
||||
var logDebug = loggerInstance.logDebug;
|
||||
|
@ -174,7 +170,6 @@ var startWebsite = function(portalConfig, poolConfigs){
|
|||
|
||||
|
||||
(function init(){
|
||||
var portalConfig = JSON.parse(JSON.minify(fs.readFileSync("config.json", {encoding: 'utf8'})));
|
||||
|
||||
var poolConfigs = buildPoolConfigs();
|
||||
|
||||
|
|
24
libs/api.js
24
libs/api.js
|
@ -1,18 +1,14 @@
|
|||
var express = require('express');
|
||||
var os = require('os');
|
||||
var app = express();
|
||||
|
||||
app.get('/getstatus', function (req, res) {
|
||||
res.send({
|
||||
'loadavg': os.loadavg(),
|
||||
'freemem': os.freemem()
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
module.exports = {
|
||||
start: function () {
|
||||
app.listen(9000);
|
||||
}
|
||||
}
|
||||
module.exports = function(logger, poolConfigs){
|
||||
|
||||
//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 logLevelInt = severityToInt(configuration.logLevel);
|
||||
|
||||
// privates
|
||||
var shouldLog = function(key, severity) {
|
||||
var keyValue = configuration.keys[key];
|
||||
if (typeof(keyValue) === 'undefined') {
|
||||
keyValue = configuration.default;
|
||||
}
|
||||
|
||||
if (typeof(keyValue) === 'boolean') {
|
||||
return keyValue;
|
||||
} else if (typeof(keyValue) === 'string') {
|
||||
return severityToInt(severity) >= severityToInt(keyValue);
|
||||
}
|
||||
}
|
||||
var severity = severityToInt(severity);
|
||||
return severity >= logLevelInt;
|
||||
};
|
||||
|
||||
var log = function(severity, key, poolName, text) {
|
||||
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);
|
||||
if (!shouldLog(key, severity))
|
||||
return;
|
||||
|
||||
}
|
||||
var desc = poolName ? '[' + poolName + '] ' : '';
|
||||
console.log(
|
||||
'\u001b['+getSeverityColor(severity)+'m' +
|
||||
dateFormat(new Date(), 'yyyy-mm-dd HH:mm:ss') +
|
||||
" ["+key+"]" + '\u001b[39m: ' + "\t" +
|
||||
desc +
|
||||
text);
|
||||
}
|
||||
'\u001b[' + getSeverityColor(severity) + 'm' +
|
||||
dateFormat(new Date(), 'yyyy-mm-dd HH:MM:ss') +
|
||||
" [" + key + "]" + '\u001b[39m: ' + "\t" +
|
||||
desc + text
|
||||
);
|
||||
};
|
||||
|
||||
// public
|
||||
|
|
@ -189,7 +189,7 @@ function SetupForPool(logger, poolOptions){
|
|||
}, 0);
|
||||
|
||||
var poolTotalRewards = rounds.reduce(function(p, c){
|
||||
return p + c.amount;
|
||||
return p + c.amount * c.magnitude;
|
||||
}, 0);
|
||||
|
||||
console.log(workerRewards);
|
||||
|
|
|
@ -44,12 +44,6 @@ module.exports = function(logger, poolConfig){
|
|||
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){
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ var dot = require('dot');
|
|||
var express = require('express');
|
||||
|
||||
|
||||
|
||||
module.exports = function(logger){
|
||||
|
||||
var portalConfig = JSON.parse(process.env.portalConfig);
|
||||
|
|
Loading…
Reference in New Issue