Move interval stuff to config keys

This commit is contained in:
calzoneman 2013-09-26 23:41:38 -05:00
parent 6bf11a57b3
commit ba66aadf66
3 changed files with 14 additions and 6 deletions

View File

@ -1,3 +1,8 @@
Thu Sep 26 23:40 2013 CDT
* lib/config.js: Add config keys for statistics interval & max age,
alias purge interval & max age.
* lib/bgtask.js: Update intervals to reflect new config keys
Thu Sep 26 23:33 2013 CDT Thu Sep 26 23:33 2013 CDT
* lib/stats.js: Remove this file, move the statistics tracking * lib/stats.js: Remove this file, move the statistics tracking
interval to the new bgtask.js interval to the new bgtask.js

View File

@ -23,8 +23,8 @@ var init = null;
/* Stats */ /* Stats */
function initStats(Server) { function initStats(Server) {
const STAT_INTERVAL = 60 * 60 * 1000; var STAT_INTERVAL = Server.cfg["stat-interval"];
const STAT_EXPIRE = 24 * STAT_INTERVAL; var STAT_EXPIRE = Server.cfg["stat-max-age"];
setInterval(function () { setInterval(function () {
var db = Server.db; var db = Server.db;
@ -44,11 +44,10 @@ function initStats(Server) {
/* Alias cleanup */ /* Alias cleanup */
function initAliasCleanup(Server) { function initAliasCleanup(Server) {
const CLEAN_INTERVAL = 60 * 60 * 1000; var CLEAN_INTERVAL = Server.cfg["alias-purge-interval"];
const CLEAN_EXPIRE = 30 * 24 * 60 * 60 * 1000; // 1 month var CLEAN_EXPIRE = Server.cfg["alias-max-age"];
setInterval(function () { setInterval(function () {
console.log("cleaning aliases");
Server.db.cleanOldAliases(CLEAN_EXPIRE, function (err) { Server.db.cleanOldAliases(CLEAN_EXPIRE, function (err) {
Logger.syslog.log("Cleaned old aliases"); Logger.syslog.log("Cleaned old aliases");
if (err) if (err)

View File

@ -44,7 +44,11 @@ var defaults = {
"domain" : "http://localhost", "domain" : "http://localhost",
"ytv3apikey" : "", "ytv3apikey" : "",
"enable-ytv3" : false, "enable-ytv3" : false,
"ytv2devkey" : "" "ytv2devkey" : "",
"stat-interval" : 3600000,
"stat-max-age" : 86400000,
"alias-purge-interval": 3600000,
"alias-max-age" : 2592000000
} }
function save(cfg, file) { function save(cfg, file) {