mirror of https://github.com/xwiki-labs/cryptpad
Merge pull request #1543 from cryptpad/memory
Server memory improvements
This commit is contained in:
commit
1b670484eb
|
@ -190,6 +190,9 @@ nThen(function (w) {
|
|||
removed++;
|
||||
}
|
||||
});
|
||||
if (Env.store) {
|
||||
Env.store.closeInactiveChannels(active);
|
||||
}
|
||||
if (removed) {
|
||||
Env.Log.info("CLEANED_ACTIVE_CHANNELS_MAP", {removed});
|
||||
}
|
||||
|
|
|
@ -146,6 +146,7 @@ const dropChannel = HK.dropChannel = function (Env, chanName) {
|
|||
expireChannel(Env, chanName);
|
||||
}, TEMPORARY_CHANNEL_LIFETIME);
|
||||
}
|
||||
if (Env.store) { Env.store.closeChannel(chanName, function () {}); }
|
||||
};
|
||||
|
||||
/* checkExpired
|
||||
|
|
|
@ -286,6 +286,16 @@ var closeChannel = function (env, channelName, cb) {
|
|||
}
|
||||
};
|
||||
|
||||
var closeInactiveChannels = function (env, schedule, active) {
|
||||
Object.keys(env.channels).forEach(channelName => {
|
||||
if (!active.includes(channelName)) {
|
||||
schedule.ordered(channelName, function (next) {
|
||||
closeChannel(env, channelName, next);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var clearOffset = function (env, channelId, cb) {
|
||||
var path = mkOffsetPath(env, channelId);
|
||||
// we should always be able to recover from invalid offsets, so failure to delete them
|
||||
|
@ -1445,6 +1455,9 @@ module.exports.create = function (conf, _cb) {
|
|||
closeChannel(env, channelName, Util.both(cb, next));
|
||||
});
|
||||
},
|
||||
closeInactiveChannels: function (active) {
|
||||
closeInactiveChannels(env, schedule, active);
|
||||
},
|
||||
// write to a log file
|
||||
log: function (channelName, content, cb) {
|
||||
// you probably want the events in your log to be in the correct order.
|
||||
|
|
Loading…
Reference in New Issue