Notify master about instance status update

Send updates to the master server when the running status of instances
change and add onInstanceStatusChanged hook to master plugins.
This commit is contained in:
Hornwitser committed 2020-05-11 18:10:11 +02:00
1 parent a8e29fdc56
commit 3211fbe985
5 files changed
+111 -16

No files matched your search

+15 -3
View File
@@ -535,17 +535,28 @@ messages.debugWsMessage = new Event({
messages.instanceInitialized = new Event({
type: "instance_initialized",
links: ["instance-slave"],
links: ["instance-slave", "slave-master"],
eventProperties: {
"instance_id": { type: "integer" },
"plugins": {
type: "object",
additionalProperties: { type: "string" },
}
},
});
messages.instanceStarted = new Event({
type: "instance_started",
links: ["instance-slave", "slave-master"],
eventProperties: {
"instance_id": { type: "integer" },
},
});
messages.instanceStopped = new Event({
type: 'instance_stopped',
links: ['instance-slave'],
links: ["instance-slave", "slave-master"],
eventProperties: {
"instance_id": { type: "integer" },
},
});
messages.updateInstances = new Event({
@@ -557,9 +568,10 @@ messages.updateInstances = new Event({
items: {
type: "object",
additionalProperties: false,
required: ["serialized_config"],
required: ["serialized_config", "status"],
properties: {
"serialized_config": { type: "object" },
"status": { enum: ["stopped", "initialized", "running"] },
},
},
},
+15
View File
@@ -163,6 +163,21 @@ class BaseMasterPlugin {
*/
async init() { }
/**
* Called when the status of an instance changes
*
* Invoked when the master server has received notice from a slave that
* the running status of an instance has changed. The possible statuses
* are `stopped` meaning it is not loaded or running, `initialized`
* meaning the instance has initialized and is starting up the Factorio
* server, and `running` which means the Factorio server it manages is
* up and running.
*
* @param {Object} instance - the instance that changed.
* @param {string} prev - the previous status of the instance.
*/
async onInstanceStatusChanged(instance, prev) { }
/**
* Called before collecting Prometheus metrics
*