define all server intervals in a map so we can easily clear them all

pull/1/head
ansuz 5 years ago
parent 3601bd6429
commit 43307ffb1a

@ -13,6 +13,7 @@ module.exports.create = function (config) {
config.store = _store;
}));
}).nThen(function (w) {
// XXX embed this in historyKeeper
require("../storage/tasks").create(config, w(function (e, tasks) {
if (e) {
throw e;
@ -20,8 +21,8 @@ module.exports.create = function (config) {
config.tasks = tasks;
if (config.disableIntegratedTasks) { return; }
// XXX support stopping this interval
setInterval(function () {
config.intervals = config.intervals || {};
config.intervals.taskExpiration = setInterval(function () {
tasks.runAll(function (err) {
if (err) {
// either TASK_CONCURRENCY or an error with tasks.list

@ -15,11 +15,20 @@ var getActiveSessions = function (Env, Server, cb) {
};
var shutdown = function (Env, Server, cb) {
if (true) {
return void cb('E_NOT_IMPLEMENTED');
//clearInterval(Env.sessionExpirationInterval);
// XXX set a flag to prevent incoming database writes
// XXX disconnect all users and reject new connections
// XXX wait until all pending writes are complete
}
// disconnect all users and reject new connections
Server.shutdown();
// stop all intervals that may be running
Object.keys(Env.intervals).forEach(function (name) {
clearInterval(Env.intervals[name]);
});
// set a flag to prevent incoming database writes
// wait until all pending writes are complete
// then process.exit(0);
// and allow system functionality to restart the server
};

@ -359,7 +359,6 @@ module.exports.create = function (cfg, cb) {
// close the channel
store.closeChannel(channel, function () {
// XXX make sure that clients actually disconnect when we broadcast an error
Server.channelBroadcast(channel, {
error: 'EEXPIRED',
channel: channel

@ -378,6 +378,7 @@ RPC.create = function (config, cb) {
var Env = {
historyKeeper: config.historyKeeper,
intervals: config.intervals || {},
defaultStorageLimit: config.defaultStorageLimit,
maxUploadSize: config.maxUploadSize || (20 * 1024 * 1024),
Sessions: {},
@ -388,7 +389,6 @@ RPC.create = function (config, cb) {
evPinnedPadsReady: mkEvent(true),
limits: {},
admins: [],
sessionExpirationInterval: undefined,
Log: Log,
WARN: WARN,
flushCache: config.flushCache,
@ -427,7 +427,7 @@ RPC.create = function (config, cb) {
};
Quota.applyCustomLimits(Env);
updateLimitDaily();
setInterval(updateLimitDaily, 24*3600*1000);
Env.intervals.dailyLimitUpdate = setInterval(updateLimitDaily, 24*3600*1000);
Pinning.loadChannelPins(Env);
@ -458,8 +458,7 @@ RPC.create = function (config, cb) {
}
});
// expire old sessions once per minute
// XXX allow for graceful shutdown
Env.sessionExpirationInterval = setInterval(function () {
Env.intervals.sessionExpirationInterval = setInterval(function () {
Core.expireSessions(Sessions);
}, Core.SESSION_EXPIRATION_TIME);
});

Loading…
Cancel
Save