From 16d5e3ea8020c839dd6e2dd192e8ccba71f39eed Mon Sep 17 00:00:00 2001 From: Cheng-Han, Wu Date: Wed, 1 Jun 2016 14:18:54 +0800 Subject: Add maintenance mode and update to gracefully exit process on signal --- lib/config.js | 2 ++ lib/realtime.js | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/config.js b/lib/config.js index 9f11c5b5..5579d61e 100644 --- a/lib/config.js +++ b/lib/config.js @@ -78,10 +78,12 @@ function getserverurl() { } var version = '0.4.0'; +var maintenance = config.maintenance || false; var cwd = path.join(__dirname, '..'); module.exports = { version: version, + maintenance: maintenance, debug: debug, urlpath: urlpath, port: port, diff --git a/lib/realtime.js b/lib/realtime.js index a8bef97a..1d142709 100644 --- a/lib/realtime.js +++ b/lib/realtime.js @@ -25,7 +25,9 @@ var realtime = { onAuthorizeFail: onAuthorizeFail, secure: secure, connection: connection, - getStatus: getStatus + getStatus: getStatus, + users: users, + notes: notes }; function onAuthorizeSuccess(data, accept) { @@ -70,8 +72,9 @@ function emitCheck(note) { } //actions -var users = {}; -var notes = {}; +var users, notes; +realtime.users = users = {}; +realtime.notes = notes = {}; //update when the note is dirty var updater = setInterval(function () { async.each(Object.keys(notes), function (key, callback) { @@ -536,6 +539,7 @@ function ifMayEdit(socket, callback) { } function connection(socket) { + if (config.maintenance) return; parseNoteIdFromSocket(socket, function (err, noteId) { if (err) { return failConnection(500, err, socket); -- cgit v1.2.3