Add concurrency to channel saving on server shutdown

This commit is contained in:
Calvin Montgomery 2016-08-31 21:46:54 -07:00
parent 5b60a48c7f
commit 7b4126c32f
2 changed files with 5 additions and 5 deletions

View File

@ -2,7 +2,7 @@
"author": "Calvin Montgomery", "author": "Calvin Montgomery",
"name": "CyTube", "name": "CyTube",
"description": "Online media synchronizer and chat", "description": "Online media synchronizer and chat",
"version": "3.21.2", "version": "3.21.3",
"repository": { "repository": {
"url": "http://github.com/calzoneman/sync" "url": "http://github.com/calzoneman/sync"
}, },

View File

@ -318,13 +318,13 @@ Server.prototype.setAnnouncement = function (data) {
Server.prototype.shutdown = function () { Server.prototype.shutdown = function () {
Logger.syslog.log("Unloading channels"); Logger.syslog.log("Unloading channels");
Promise.reduce(this.channels, (_, channel) => { Promise.map(this.channels, channel => {
return channel.saveState().tap(() => { return channel.saveState().tap(() => {
Logger.syslog.log(`Saved /r/${channel.name}`); Logger.syslog.log(`Saved /r/${channel.name}`);
}).catch(err => { }).catch(err => {
Logger.errlog.log(`Failed to save /r/${channel.name}: ${err.stack}`); Logger.errlog.log(`Failed to save /r/${channel.name}: ${err.stack}`);
}); });
}).then(() => { }, { concurrency: 5 }).then(() => {
Logger.syslog.log("Goodbye"); Logger.syslog.log("Goodbye");
process.exit(0); process.exit(0);
}).catch(err => { }).catch(err => {
@ -348,7 +348,7 @@ Server.prototype.reloadPartitionMap = function () {
this.initModule.partitionConfig.config = config.config; this.initModule.partitionConfig.config = config.config;
const channels = Array.prototype.slice.call(this.channels); const channels = Array.prototype.slice.call(this.channels);
Promise.reduce(channels, (_, channel) => { Promise.map(channels, channel => {
if (channel.dead) { if (channel.dead) {
return; return;
} }
@ -371,7 +371,7 @@ Server.prototype.reloadPartitionMap = function () {
`partition map flip: ${error.stack}`); `partition map flip: ${error.stack}`);
}); });
} }
}, 0).then(() => { }, { concurrency: 5 }).then(() => {
Logger.syslog.log("Partition reload complete"); Logger.syslog.log("Partition reload complete");
}); });
}; };