Forward Factorio logs to clusterctl

Add instance output event that is forwarded by the master server to
control connections that are subscribing to them.  Add code subscribing
to the relevant instance output when dealing with instances in
clusterctl.
This commit is contained in:
Hornwitser committed 2019-11-23 15:18:20 +01:00
1 parent f2c3006046
commit 1dea5fddbe
4 files changed
+139 -12

No files matched your search

+15
View File
@@ -283,6 +283,8 @@ class ControlConnection extends BaseConnection {
controlConnections.splice(index, 1);
}
});
this.instanceOutputSubscriptions = new Set();
}
async listSlavesRequestHandler(message) {
@@ -334,6 +336,10 @@ class ControlConnection extends BaseConnection {
}
});
}
async setInstanceOutputSubscriptionsRequestHandler(message) {
this.instanceOutputSubscriptions = new Set(message.data.instance_ids);
}
}
var slaveConnections = new Map();
@@ -403,6 +409,15 @@ class SlaveConnection extends BaseConnection {
});
}
}
async instanceOutputEventHandler(message) {
let { instance_id, output } = message.data;
for (let controlConnection of controlConnections) {
if (controlConnection.instanceOutputSubscriptions.has(instance_id)) {
link.events.instanceOutput.send(controlConnection, message.data);
}
}
}
}
// Authentication middleware for socket.io connections