implement an admin command to update the default storage limit without a restart

pull/1/head
ansuz 5 years ago
parent f345998956
commit b2fcde87d8

@ -110,6 +110,23 @@ var flushCache = function (Env, Server, cb) {
cb(void 0, true);
};
// CryptPad_AsyncStore.rpc.send('ADMIN', ['SET_DEFAULT_STORAGE_LIMIT', 1024 * 1024 * 1024 /* 1GB */], console.log)
var setDefaultStorageLimit = function (Env, Server, cb, data) {
var value = Array.isArray(data) && data[1];
if (typeof(value) !== 'number' || value <= 0) { return void cb('EINVAL'); }
var previous = Env.defaultStorageLimit;
var change = {
previous: previous,
current: value,
};
Env.defaultStorageLimit = value;
Env.Log.info('DEFAULT_STORAGE_LIMIT_UPDATE', change);
cb(void 0, change);
};
var commands = {
ACTIVE_SESSIONS: getActiveSessions,
ACTIVE_PADS: getActiveChannelCount,
@ -119,6 +136,7 @@ var commands = {
SHUTDOWN: shutdown,
GET_FILE_DESCRIPTOR_COUNT: getFileDescriptorCount,
GET_FILE_DESCRIPTOR_LIMIT: getFileDescriptorLimit,
SET_DEFAULT_STORAGE_LIMIT: setDefaultStorageLimit,
};
Admin.command = function (Env, safeKey, data, _cb, Server) {
@ -133,7 +151,7 @@ Admin.command = function (Env, safeKey, data, _cb, Server) {
var command = commands[data[0]];
if (typeof(command) === 'function') {
return void command(Env, Server, cb);
return void command(Env, Server, cb, data);
}
return void cb('UNHANDLED_ADMIN_COMMAND');

Loading…
Cancel
Save