sketch out a method for graceful shutdown

pull/1/head
ansuz 5 years ago
parent 873a7c7c84
commit c146125283

@ -1318,6 +1318,16 @@ var getActiveSessions = function (Env, ctx, cb) {
cb (void 0, [total, ips.length]); cb (void 0, [total, ips.length]);
}; };
var shutdown = function (Env, ctx, cb) {
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
// then process.exit(0);
// and allow system functionality to restart the server
};
var adminCommand = function (Env, ctx, publicKey, config, data, cb) { var adminCommand = function (Env, ctx, publicKey, config, data, cb) {
var admins = Env.admins; var admins = Env.admins;
if (admins.indexOf(publicKey) === -1) { if (admins.indexOf(publicKey) === -1) {
@ -1336,6 +1346,8 @@ var adminCommand = function (Env, ctx, publicKey, config, data, cb) {
case 'FLUSH_CACHE': case 'FLUSH_CACHE':
config.flushCache(); config.flushCache();
return cb(void 0, true); return cb(void 0, true);
case 'SHUTDOWN':
return shutdown(Env, ctx, cb);
default: default:
return cb('UNHANDLED_ADMIN_COMMAND'); return cb('UNHANDLED_ADMIN_COMMAND');
} }
@ -1806,7 +1818,8 @@ RPC.create = function (config, cb) {
}).nThen(function () { }).nThen(function () {
cb(void 0, rpc); cb(void 0, rpc);
// expire old sessions once per minute // expire old sessions once per minute
setInterval(function () { // XXX allow for graceful shutdown
Env.sessionExpirationInterval = setInterval(function () {
expireSessions(Sessions); expireSessions(Sessions);
}, SESSION_EXPIRATION_TIME); }, SESSION_EXPIRATION_TIME);
}); });

Loading…
Cancel
Save