Browse Source

minor cleanup

- cleaner startup for influx when configured
- add back exchange-rate logging that was accidentally deleted
fix-133-memory-crash
Dan Janosik 6 years ago
parent
commit
ce02f3f444
  1. 8
      app.js
  2. 16
      app/utils.js

8
app.js

@ -226,14 +226,16 @@ app.runOnStartup = function() {
timeout: 5000
});
coreApi.getNetworkInfo().then(function(getnetworkinfo) {
console.log("Connected via RPC to node. Basic info: version=" + getnetworkinfo.version + ", subversion=" + getnetworkinfo.subversion + ", protocolversion=" + getnetworkinfo.protocolversion + ", services=" + getnetworkinfo.localservices);
if (config.credentials.influxdb.active) {
global.influxdb = new Influx.InfluxDB(config.credentials.influxdb);
console.log(`Connected to InfluxDB: ${config.credentials.influxdb.host}:${config.credentials.influxdb.port}/${config.credentials.influxdb.database}`);
}
coreApi.getNetworkInfo().then(function(getnetworkinfo) {
console.log("Connected via RPC to node. Basic info: version=" + getnetworkinfo.version + ", subversion=" + getnetworkinfo.subversion + ", protocolversion=" + getnetworkinfo.protocolversion + ", services=" + getnetworkinfo.localservices);
if (global.influxdb != null) {
logNetworkStats();
setInterval(logNetworkStats, 1 * 60000);

16
app/utils.js

@ -290,6 +290,22 @@ function refreshExchangeRates() {
global.exchangeRates = exchangeRates;
global.exchangeRatesUpdateTime = new Date();
if (global.influxdb) {
var points = [];
for (var key in exchangeRates) {
points.push({
measurement: `exchange_rates.${coins[config.coin].ticker.toLowerCase()}_${key.toLowerCase()}`,
fields:{value:parseFloat(exchangeRates[key])}
});
}
//console.log("pts: " + JSON.stringify(points));
global.influxdb.writePoints(points).catch(err => {
console.error(`Error saving data to InfluxDB: ${err.stack}`)
});
}
console.log("Using exchange rates: " + JSON.stringify(global.exchangeRates) + " starting at " + global.exchangeRatesUpdateTime);
} else {

Loading…
Cancel
Save