add code to detect SDK prediction stalls
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
const { log, flushLog } = require("./log.js")("master");
|
||||
const cp = require("child_process");
|
||||
const DlFactory = require("./DlFactory.js");
|
||||
//const abrsdk = require("adblockradio-sdk")(require("./log.js")("sdk").log);
|
||||
const abrsdk = require("../adblockradio-sdk/libabr.js")(require("./log.js")("sdk(local)").log);
|
||||
const abrsdk = require("adblockradio-sdk")(require("./log.js")("sdk").log);
|
||||
//const abrsdk = require("../adblockradio-sdk/libabr.js")(require("./log.js")("sdk(local)").log);
|
||||
|
||||
const FETCH_METADATA = true;
|
||||
const SAVE_AUDIO = false;
|
||||
@@ -18,6 +18,8 @@ var USE_ABRSDK = true;
|
||||
var { config, getRadios, getUserConfig, insertRadio, removeRadio, toggleContent, getAvailableInactive } = require("./config.js");
|
||||
|
||||
var dl = [];
|
||||
var lastPrediction = new Date();
|
||||
|
||||
var updateDlList = function(forcePlaylistUpdate) {
|
||||
var playlistChange = false || !!forcePlaylistUpdate;
|
||||
|
||||
@@ -65,6 +67,16 @@ var updateDlList = function(forcePlaylistUpdate) {
|
||||
for (var i=0; i<config.radios.length; i++) {
|
||||
playlistArray.push(config.radios[i].country + "_" + config.radios[i].name);
|
||||
}
|
||||
|
||||
var predInterval = setInterval(function() {
|
||||
let age = +new Date() - lastPrediction;
|
||||
if (age > 15000) {
|
||||
log.warn("abrsdk: last prediction received " + Math.round(age/1000) + "s ago");
|
||||
clearInterval(predInterval);
|
||||
updateDlList(true);
|
||||
}
|
||||
}, 5000);
|
||||
|
||||
abrsdk.sendPlaylist(playlistArray, config.user.token, function(err, validatedPlaylist) {
|
||||
if (err) {
|
||||
log.warn("abrsdk: sendPlaylist error = " + err);
|
||||
@@ -74,14 +86,6 @@ var updateDlList = function(forcePlaylistUpdate) {
|
||||
} else {
|
||||
log.debug("abrsdk: playlist successfully updated");
|
||||
}
|
||||
var lastPrediction = new Date();
|
||||
|
||||
setInterval(function() {
|
||||
let age = +new Date() - lastPrediction;
|
||||
if (age > 15000) {
|
||||
log.warn("abrsdk: last prediction received " + Math.round(age/1000) + "s ago");
|
||||
}
|
||||
}, 5000);
|
||||
|
||||
abrsdk.setPredictionCallback(function(predictions) {
|
||||
let age = +new Date() - lastPrediction;
|
||||
|
||||
Generated
+3
-3
@@ -1978,9 +1978,9 @@
|
||||
}
|
||||
},
|
||||
"webradio-metadata": {
|
||||
"version": "0.1.12",
|
||||
"resolved": "https://registry.npmjs.org/webradio-metadata/-/webradio-metadata-0.1.12.tgz",
|
||||
"integrity": "sha512-uKOCKmsN1tCUzhgSEH0rXyB+t573UkMeaFXxO9/WWm+qh/tY7N1GA5Nkt6RbvYyRfeQe0ZUqBcEvo05SvuG+VQ==",
|
||||
"version": "0.1.15",
|
||||
"resolved": "https://registry.npmjs.org/webradio-metadata/-/webradio-metadata-0.1.15.tgz",
|
||||
"integrity": "sha512-Tuue71q1aEZg2Bls0LoWi3SlSMRJuF+uF7Z/e7FducahMWeIbKSNyl8mZjY76D9KQCOl9XdXxvmcbMO6Zt2DDA==",
|
||||
"requires": {
|
||||
"chalk": "2.3.2",
|
||||
"loglevel": "1.6.1",
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
"express": "^4.16.3",
|
||||
"jsonwebtoken": "^8.2.0",
|
||||
"moment": "^2.21.0",
|
||||
"webradio-metadata": "^0.1.x",
|
||||
"webradio-metadata": "^0.1.15",
|
||||
"winston": "^3.0.0-rc3",
|
||||
"winston-daily-rotate-file": "^3.0.1"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user