mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-13 07:04:53 +09:00
Add auto_start config option to instances
Add option to automatically start the instance on slave startup.
This commit is contained in:
1 parent
9d2ac2b81f
commit
87da492ef8
3 files changed
+28
No files matched your search
@@ -48,6 +48,7 @@ Version 2.0.0
|
|||||||
Clusterio core. Previously this was handled by the playerManager plugin.
|
Clusterio core. Previously this was handled by the playerManager plugin.
|
||||||
- Added stripping of long paths in the Factorio server log.
|
- Added stripping of long paths in the Factorio server log.
|
||||||
- Added option to configure maximum number of commands to send in parallel.
|
- Added option to configure maximum number of commands to send in parallel.
|
||||||
|
- Added option to auto start instances on slave startup.
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
|
|
||||||
|
|||||||
@@ -196,6 +196,12 @@ InstanceGroup.define({
|
|||||||
type: "number",
|
type: "number",
|
||||||
optional: true,
|
optional: true,
|
||||||
});
|
});
|
||||||
|
InstanceGroup.define({
|
||||||
|
name: "auto_start",
|
||||||
|
description: "Automatically start this instance when the slave hosting it is started up",
|
||||||
|
type: "boolean",
|
||||||
|
initial_value: false,
|
||||||
|
});
|
||||||
InstanceGroup.finalize();
|
InstanceGroup.finalize();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -924,6 +924,7 @@ class Slave extends libLink.Link {
|
|||||||
this.serverPlugins = new Map(Object.entries(data.plugins));
|
this.serverPlugins = new Map(Object.entries(data.plugins));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this._startup = true;
|
||||||
this._disconnecting = false;
|
this._disconnecting = false;
|
||||||
this._shuttingDown = false;
|
this._shuttingDown = false;
|
||||||
|
|
||||||
@@ -1296,6 +1297,26 @@ class Slave extends libLink.Link {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
await libLink.messages.updateInstances.send(this, { instances: list });
|
await libLink.messages.updateInstances.send(this, { instances: list });
|
||||||
|
|
||||||
|
// Handle configured auto startup instances
|
||||||
|
if (this._startup) {
|
||||||
|
this._startup = false;
|
||||||
|
|
||||||
|
for (let [instanceId, instanceInfo] of this.instanceInfos) {
|
||||||
|
if (instanceInfo.config.get("instance.auto_start")) {
|
||||||
|
try {
|
||||||
|
let instanceConnection = await this._connectInstance(instanceId);
|
||||||
|
await libLink.messages.startInstance.send(instanceConnection, {
|
||||||
|
instance_id: instanceId,
|
||||||
|
save: null,
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error(`Error during auto startup for ${instanceInfo.config.get("instance.name")}:`);
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async prepareDisconnectRequestHandler(message, request) {
|
async prepareDisconnectRequestHandler(message, request) {
|
||||||
|
|||||||
Reference in new issue
Block a user