Multi rtorrent instances support (#638)

* Multi rtorrent instances support (#549)

* Handling multiple rtorrent instances

* performance issue addressing

* fix wrong conflict resolution

* performances

* purge services instance every 10 mins

* last fixes

* avoid duplicated reducers

* Adjusts UI of rtorrent connection form fields (#639)

* Multi rtorrent instance cleanup (#676)

* Cleans up multi-user logic.

* Rename clientRequestService to clientGatewayService

* [multi-user] Adds prompt to fix rtorrent connection failure (#681)

* Adds ability to update user

* Add connection test endpoints and client actions

* Listen to client connectivity change events

* Separates scgiUtil from clientRequestManager

* Adds BaseService

* Services extend BaseService

* Listen for connetion change events in client

* Reorganizes app structure

* Adds prompt to correct per-user client interruption

* Fixes linting errors

* Removes debugging stuff

* Fixes Size rendering

* Fixes moveTorrents

* Adds migration step for legacy database entries (#686)

* Use FormattedMessage

* Updates documentation

* Fixes migration script for new installs

* Updates dependencies

* Moves string to i18n

* Updates deps
This commit is contained in:
John Furrow
2018-09-02 00:15:21 -07:00
committed by GitHub
parent cccce3617b
commit f492ad348a
60 changed files with 4818 additions and 4244 deletions
+6
View File
@@ -0,0 +1,6 @@
const services = require('../services');
module.exports = (req, res, next) => {
req.services = services.getAllServices(req.user);
next();
};
+35 -24
View File
@@ -1,32 +1,34 @@
'use strict';
const historyService = require('../services/historyService');
const clientGatewayServiceEvents = require('../constants/clientGatewayServiceEvents');
const historyServiceEvents = require('../constants/historyServiceEvents');
const historySnapshotTypes = require('../../shared/constants/historySnapshotTypes');
const notificationService = require('../services/notificationService');
const notificationServiceEvents = require('../constants/notificationServiceEvents');
const ServerEvent = require('../models/ServerEvent');
const serverEventTypes = require('../../shared/constants/serverEventTypes');
const taxonomyService = require('../services/taxonomyService');
const services = require('../services');
const taxonomyServiceEvents = require('../constants/taxonomyServiceEvents');
const torrentService = require('../services/torrentService');
const torrentServiceEvents = require('../constants/torrentServiceEvents');
module.exports = (req, res) => {
const {query: {historySnapshot = historySnapshotTypes.FIVE_MINUTE}} = req;
const {query: {historySnapshot = historySnapshotTypes.FIVE_MINUTE}, user} = req;
const serviceInstances = services.getAllServices(user);
const serverEvent = new ServerEvent(res);
const taxonomy = taxonomyService.getTaxonomy();
const torrentList = torrentService.getTorrentList();
const transferSummary = historyService.getTransferSummary();
const taxonomy = serviceInstances.taxonomyService.getTaxonomy();
const torrentList = serviceInstances.torrentService.getTorrentList();
const transferSummary = serviceInstances.historyService.getTransferSummary();
// Remove all previous event listeners.
historyService.removeAllListeners();
notificationService.removeAllListeners();
taxonomyService.removeAllListeners();
torrentService.removeAllListeners();
serviceInstances.historyService.removeAllListeners();
serviceInstances.notificationService.removeAllListeners();
serviceInstances.taxonomyService.removeAllListeners();
serviceInstances.torrentService.removeAllListeners();
// Emit current state immediately on connection.
serverEvent.setID(Date.now());
serverEvent.setType(serverEventTypes.CLIENT_CONNECTIVITY_STATUS_CHANGE);
serverEvent.addData({isConnected: !serviceInstances.clientGatewayService.hasError});
serverEvent.emit();
// Emit all existing data.
serverEvent.setID(torrentList.id);
serverEvent.setType(serverEventTypes.TORRENT_LIST_FULL_UPDATE);
serverEvent.addData(torrentList.torrents);
@@ -42,14 +44,24 @@ module.exports = (req, res) => {
serverEvent.addData(transferSummary.transferSummary);
serverEvent.emit();
serverEvent.setID({id: Date.now()});
serverEvent.setID(Date.now());
serverEvent.setType(serverEventTypes.NOTIFICATION_COUNT_CHANGE);
serverEvent.addData(notificationService.getNotificationCount());
serverEvent.addData(serviceInstances.notificationService.getNotificationCount());
serverEvent.emit();
serviceInstances.clientGatewayService.on(
clientGatewayServiceEvents.CLIENT_CONNECTION_STATE_CHANGE,
() => {
serverEvent.setID(Date.now());
serverEvent.setType(serverEventTypes.CLIENT_CONNECTIVITY_STATUS_CHANGE);
serverEvent.addData({isConnected: !serviceInstances.clientGatewayService.hasError});
serverEvent.emit();
}
);
// TODO: Handle empty or sub-optimal history states.
// Get user's specified history snapshot current history.
historyService.getHistory({snapshot: historySnapshot}, (snapshot, error) => {
serviceInstances.historyService.getHistory({snapshot: historySnapshot}, (snapshot, error) => {
const {timestamps: lastTimestamps = []} = snapshot;
const lastTimestamp = lastTimestamps[lastTimestamps.length - 1];
@@ -61,9 +73,8 @@ module.exports = (req, res) => {
}
});
// Add user's specified history snapshot change event listener.
historyService.on(
serviceInstances.historyService.on(
historyServiceEvents[
`${historySnapshotTypes[historySnapshot]}_SNAPSHOT_FULL_UPDATE`
],
@@ -77,7 +88,7 @@ module.exports = (req, res) => {
}
);
notificationService.on(
serviceInstances.notificationService.on(
notificationServiceEvents.NOTIFICATION_COUNT_CHANGE,
payload => {
const {data, id} = payload;
@@ -90,7 +101,7 @@ module.exports = (req, res) => {
);
// Add diff event listeners.
historyService.on(
serviceInstances.historyService.on(
historyServiceEvents.TRANSFER_SUMMARY_DIFF_CHANGE,
(payload) => {
const {diff, id} = payload;
@@ -102,7 +113,7 @@ module.exports = (req, res) => {
}
);
taxonomyService.on(
serviceInstances.taxonomyService.on(
taxonomyServiceEvents.TAXONOMY_DIFF_CHANGE,
(payload) => {
const {diff, id} = payload;
@@ -114,7 +125,7 @@ module.exports = (req, res) => {
}
);
torrentService.on(
serviceInstances.torrentService.on(
torrentServiceEvents.TORRENT_LIST_DIFF_CHANGE,
(payload) => {
const {diff, id} = payload;
-2
View File
@@ -1,5 +1,3 @@
'use strict';
module.exports = (req, res, next) => {
req.socket.setKeepAlive(true);
req.socket.setTimeout(0);