define all server intervals in a map so we can easily clear them all
This commit is contained in:
parent
3601bd6429
commit
43307ffb1a
@ -13,6 +13,7 @@ module.exports.create = function (config) {
|
|||||||
config.store = _store;
|
config.store = _store;
|
||||||
}));
|
}));
|
||||||
}).nThen(function (w) {
|
}).nThen(function (w) {
|
||||||
|
// XXX embed this in historyKeeper
|
||||||
require("../storage/tasks").create(config, w(function (e, tasks) {
|
require("../storage/tasks").create(config, w(function (e, tasks) {
|
||||||
if (e) {
|
if (e) {
|
||||||
throw e;
|
throw e;
|
||||||
@ -20,8 +21,8 @@ module.exports.create = function (config) {
|
|||||||
config.tasks = tasks;
|
config.tasks = tasks;
|
||||||
if (config.disableIntegratedTasks) { return; }
|
if (config.disableIntegratedTasks) { return; }
|
||||||
|
|
||||||
// XXX support stopping this interval
|
config.intervals = config.intervals || {};
|
||||||
setInterval(function () {
|
config.intervals.taskExpiration = setInterval(function () {
|
||||||
tasks.runAll(function (err) {
|
tasks.runAll(function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
// either TASK_CONCURRENCY or an error with tasks.list
|
// 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) {
|
var shutdown = function (Env, Server, cb) {
|
||||||
return void cb('E_NOT_IMPLEMENTED');
|
if (true) {
|
||||||
//clearInterval(Env.sessionExpirationInterval);
|
return void cb('E_NOT_IMPLEMENTED');
|
||||||
// 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);
|
// then process.exit(0);
|
||||||
// and allow system functionality to restart the server
|
// and allow system functionality to restart the server
|
||||||
};
|
};
|
||||||
|
|||||||
@ -359,7 +359,6 @@ module.exports.create = function (cfg, cb) {
|
|||||||
|
|
||||||
// close the channel
|
// close the channel
|
||||||
store.closeChannel(channel, function () {
|
store.closeChannel(channel, function () {
|
||||||
// XXX make sure that clients actually disconnect when we broadcast an error
|
|
||||||
Server.channelBroadcast(channel, {
|
Server.channelBroadcast(channel, {
|
||||||
error: 'EEXPIRED',
|
error: 'EEXPIRED',
|
||||||
channel: channel
|
channel: channel
|
||||||
|
|||||||
@ -378,6 +378,7 @@ RPC.create = function (config, cb) {
|
|||||||
|
|
||||||
var Env = {
|
var Env = {
|
||||||
historyKeeper: config.historyKeeper,
|
historyKeeper: config.historyKeeper,
|
||||||
|
intervals: config.intervals || {},
|
||||||
defaultStorageLimit: config.defaultStorageLimit,
|
defaultStorageLimit: config.defaultStorageLimit,
|
||||||
maxUploadSize: config.maxUploadSize || (20 * 1024 * 1024),
|
maxUploadSize: config.maxUploadSize || (20 * 1024 * 1024),
|
||||||
Sessions: {},
|
Sessions: {},
|
||||||
@ -388,7 +389,6 @@ RPC.create = function (config, cb) {
|
|||||||
evPinnedPadsReady: mkEvent(true),
|
evPinnedPadsReady: mkEvent(true),
|
||||||
limits: {},
|
limits: {},
|
||||||
admins: [],
|
admins: [],
|
||||||
sessionExpirationInterval: undefined,
|
|
||||||
Log: Log,
|
Log: Log,
|
||||||
WARN: WARN,
|
WARN: WARN,
|
||||||
flushCache: config.flushCache,
|
flushCache: config.flushCache,
|
||||||
@ -427,7 +427,7 @@ RPC.create = function (config, cb) {
|
|||||||
};
|
};
|
||||||
Quota.applyCustomLimits(Env);
|
Quota.applyCustomLimits(Env);
|
||||||
updateLimitDaily();
|
updateLimitDaily();
|
||||||
setInterval(updateLimitDaily, 24*3600*1000);
|
Env.intervals.dailyLimitUpdate = setInterval(updateLimitDaily, 24*3600*1000);
|
||||||
|
|
||||||
Pinning.loadChannelPins(Env);
|
Pinning.loadChannelPins(Env);
|
||||||
|
|
||||||
@ -458,8 +458,7 @@ RPC.create = function (config, cb) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
// expire old sessions once per minute
|
// expire old sessions once per minute
|
||||||
// XXX allow for graceful shutdown
|
Env.intervals.sessionExpirationInterval = setInterval(function () {
|
||||||
Env.sessionExpirationInterval = setInterval(function () {
|
|
||||||
Core.expireSessions(Sessions);
|
Core.expireSessions(Sessions);
|
||||||
}, Core.SESSION_EXPIRATION_TIME);
|
}, Core.SESSION_EXPIRATION_TIME);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user