Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Backend setting for max log size #144

Merged
merged 1 commit into from

1 participant

Eric Barch
Eric Barch
Collaborator

No description provided.

Eric Barch ericbarch merged commit 1de4bcc into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 15, 2012
  1. Eric Barch
This page is out of date. Refresh to see the latest.
Showing with 22 additions and 1 deletion.
  1. +4 −0 config.js
  2. +18 −1 lib/irclink.js
4 config.js
View
@@ -9,3 +9,7 @@ exports.prod = {
client_port: 80, // Websockets talk on port 80 on Nodester, regardless of listen port
mongoose_auth: 'mongodb://mongodb@localhost/subway'
}
+
+exports.misc = {
+ max_log_size: 32000
+}
19 lib/irclink.js
View
@@ -1,5 +1,6 @@
var irc = require('irc'),
- mongoose = require('mongoose');
+ mongoose = require('mongoose'),
+ config = require('../config');
// establish models
var User = mongoose.model('User');
@@ -160,6 +161,22 @@ IRCLink.prototype = {
if (this.username) {
var message = new Message({channel: target.toLowerCase(), server: this.server.toLowerCase(), linkedto: this.username, user: from, message: msg});
message.save();
+
+ // keep log size in check
+ Message.count({}, function(err, count) {
+ if (count > config.misc.max_log_size) {
+ var query = Message.find({});
+
+ query.limit(count - config.misc.max_log_size);
+ query.sort('date', 1);
+
+ query.exec(function (err, records) {
+ records.forEach(function(record){
+ record.remove();
+ });
+ });
+ }
+ });
}
}
};
Something went wrong with that request. Please try again.