mirror of https://github.com/calzoneman/sync.git
Change channel dumping to a single interval rather than per-channel
This commit is contained in:
parent
9193423923
commit
2e77cb4499
|
@ -1,3 +1,8 @@
|
||||||
|
Mon Oct 14 16:37 2013 CDT
|
||||||
|
* lib/bgtask.js: Add an interval for dumping all loaded channels
|
||||||
|
* lib/channel.js: Remove per-channel dump interval
|
||||||
|
* lib/config.js: Add config key for channel save interval
|
||||||
|
|
||||||
Mon Oct 14 16:30 2013 CDT
|
Mon Oct 14 16:30 2013 CDT
|
||||||
* lib/server.js: Rate-limit socket.io connections
|
* lib/server.js: Rate-limit socket.io connections
|
||||||
* lib/bgtask.js: Periodically clear out old rate limiters
|
* lib/bgtask.js: Periodically clear out old rate limiters
|
||||||
|
|
|
@ -67,6 +67,18 @@ function initIpThrottleCleanup(Server) {
|
||||||
}, 5 * 60 * 1000);
|
}, 5 * 60 * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initChannelDumper(Server) {
|
||||||
|
var CHANNEL_SAVE_INTERVAL = Server.cfg["channel-save-interval"] * 60000;
|
||||||
|
setInterval(function () {
|
||||||
|
for (var i = 0; i < Server.channels.length; i++) {
|
||||||
|
var chan = Server.channels[i];
|
||||||
|
if (!chan.dead && chan.users && chan.users.length > 0) {
|
||||||
|
chan.saveDump();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, CHANNEL_SAVE_INTERVAL);
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = function (Server) {
|
module.exports = function (Server) {
|
||||||
if (init === Server) {
|
if (init === Server) {
|
||||||
Logger.errlog.log("WARNING: Attempted to re-init background tasks");
|
Logger.errlog.log("WARNING: Attempted to re-init background tasks");
|
||||||
|
@ -77,4 +89,5 @@ module.exports = function (Server) {
|
||||||
initStats(Server);
|
initStats(Server);
|
||||||
initAliasCleanup(Server);
|
initAliasCleanup(Server);
|
||||||
initIpThrottleCleanup(Server);
|
initIpThrottleCleanup(Server);
|
||||||
|
initChannelDumper(Server);
|
||||||
};
|
};
|
||||||
|
|
|
@ -276,7 +276,6 @@ Channel.prototype.loadDump = function() {
|
||||||
self.js = data.js || "";
|
self.js = data.js || "";
|
||||||
self.sendAll("channelCSSJS", {css: self.css, js: self.js});
|
self.sendAll("channelCSSJS", {css: self.css, js: self.js});
|
||||||
self.initialized = true;
|
self.initialized = true;
|
||||||
setTimeout(function() { incrementalDump(self); }, 300000);
|
|
||||||
}
|
}
|
||||||
catch(e) {
|
catch(e) {
|
||||||
Logger.errlog.log("Channel dump load failed: ");
|
Logger.errlog.log("Channel dump load failed: ");
|
||||||
|
@ -312,14 +311,6 @@ Channel.prototype.saveDump = function() {
|
||||||
fs.writeFileSync(path.join(__dirname, "../chandump", this.name), text);
|
fs.writeFileSync(path.join(__dirname, "../chandump", this.name), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save channel dumps every 5 minutes, in case of crash
|
|
||||||
function incrementalDump(chan) {
|
|
||||||
if(!chan.dead && chan.users && chan.users.length > 0) {
|
|
||||||
chan.saveDump();
|
|
||||||
setTimeout(function() { incrementalDump(chan); }, 300000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Channel.prototype.readLog = function (filterIp, callback) {
|
Channel.prototype.readLog = function (filterIp, callback) {
|
||||||
var maxLen = 100000; // Most recent 100KB
|
var maxLen = 100000; // Most recent 100KB
|
||||||
var file = this.logger.filename;
|
var file = this.logger.filename;
|
||||||
|
|
|
@ -14,41 +14,42 @@ var Logger = require("./logger");
|
||||||
var nodemailer = require("nodemailer");
|
var nodemailer = require("nodemailer");
|
||||||
|
|
||||||
var defaults = {
|
var defaults = {
|
||||||
"mysql-server" : "localhost",
|
"mysql-server" : "localhost",
|
||||||
"mysql-db" : "cytube",
|
"mysql-db" : "cytube",
|
||||||
"mysql-user" : "cytube",
|
"mysql-user" : "cytube",
|
||||||
"mysql-pw" : "supersecretpass",
|
"mysql-pw" : "supersecretpass",
|
||||||
"express-host" : "0.0.0.0",
|
"express-host" : "0.0.0.0",
|
||||||
"io-host" : "0.0.0.0",
|
"io-host" : "0.0.0.0",
|
||||||
"enable-ssl" : false,
|
"enable-ssl" : false,
|
||||||
"ssl-keyfile" : "",
|
"ssl-keyfile" : "",
|
||||||
"ssl-passphrase" : "",
|
"ssl-passphrase" : "",
|
||||||
"ssl-certfile" : "",
|
"ssl-certfile" : "",
|
||||||
"ssl-port" : 443,
|
"ssl-port" : 443,
|
||||||
"asset-cache-ttl" : 0,
|
"asset-cache-ttl" : 0,
|
||||||
"web-port" : 8080,
|
"web-port" : 8080,
|
||||||
"io-port" : 1337,
|
"io-port" : 1337,
|
||||||
"ip-connection-limit" : 10,
|
"ip-connection-limit" : 10,
|
||||||
"guest-login-delay" : 60,
|
"guest-login-delay" : 60,
|
||||||
"trust-x-forward" : false,
|
"channel-save-interval" : 5,
|
||||||
"enable-mail" : false,
|
"trust-x-forward" : false,
|
||||||
"mail-transport" : "SMTP",
|
"enable-mail" : false,
|
||||||
"mail-config" : {
|
"mail-transport" : "SMTP",
|
||||||
|
"mail-config" : {
|
||||||
"service" : "Gmail",
|
"service" : "Gmail",
|
||||||
"auth" : {
|
"auth" : {
|
||||||
"user" : "some.user@gmail.com",
|
"user" : "some.user@gmail.com",
|
||||||
"pass" : "supersecretpassword"
|
"pass" : "supersecretpassword"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mail-from" : "some.user@gmail.com",
|
"mail-from" : "some.user@gmail.com",
|
||||||
"domain" : "http://localhost",
|
"domain" : "http://localhost",
|
||||||
"ytv3apikey" : "",
|
"ytv3apikey" : "",
|
||||||
"enable-ytv3" : false,
|
"enable-ytv3" : false,
|
||||||
"ytv2devkey" : "",
|
"ytv2devkey" : "",
|
||||||
"stat-interval" : 3600000,
|
"stat-interval" : 3600000,
|
||||||
"stat-max-age" : 86400000,
|
"stat-max-age" : 86400000,
|
||||||
"alias-purge-interval": 3600000,
|
"alias-purge-interval" : 3600000,
|
||||||
"alias-max-age" : 2592000000
|
"alias-max-age" : 2592000000
|
||||||
}
|
}
|
||||||
|
|
||||||
function save(cfg, file) {
|
function save(cfg, file) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ The above copyright notice and this permission notice shall be included in all c
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const VERSION = "2.4.3";
|
const VERSION = "2.4.4";
|
||||||
var singleton = null;
|
var singleton = null;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"author": "Calvin Montgomery",
|
"author": "Calvin Montgomery",
|
||||||
"name": "CyTube",
|
"name": "CyTube",
|
||||||
"description": "Online media synchronizer and chat",
|
"description": "Online media synchronizer and chat",
|
||||||
"version": "2.4.3",
|
"version": "2.4.4",
|
||||||
"repository": {
|
"repository": {
|
||||||
"url": "http://github.com/calzoneman/sync"
|
"url": "http://github.com/calzoneman/sync"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue