mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 08:13:12 +09:00
Handle errors during instance startup
Catch errors and shut down the instance in question if the startup failed. This happens if for example the Factorio server errors out on a script during startup.
This commit is contained in:
1 parent
6a8346186f
commit
ddd2027739
1 file changed
+22
-3
@@ -567,14 +567,33 @@ class Slave extends link.Link {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async startInstanceRequestHandler(message, request) {
|
async startInstanceRequestHandler(message, request) {
|
||||||
let instanceConnection = await this._connectInstance(message.data.instance_id);
|
let instanceId = message.data.instance_id;
|
||||||
return await request.send(instanceConnection, message.data);
|
let instanceConnection = await this._connectInstance(instanceId);
|
||||||
|
try {
|
||||||
|
return await request.send(instanceConnection, message.data);
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
await this.stopInstance(instanceId);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async createSaveRequestHandler(message, request) {
|
async createSaveRequestHandler(message, request) {
|
||||||
let instanceId = message.data.instance_id;
|
let instanceId = message.data.instance_id;
|
||||||
let instanceConnection = await this._connectInstance(instanceId);
|
let instanceConnection = await this._connectInstance(instanceId);
|
||||||
await request.send(instanceConnection, message.data);
|
try {
|
||||||
|
await request.send(instanceConnection, message.data);
|
||||||
|
this.instanceConnections.delete(instanceId);
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
await this.stopInstance(instanceId);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async stopInstance(instanceId) {
|
||||||
|
let instanceConnection = this.instanceConnections.get(instanceId);
|
||||||
|
await link.messages.stopInstance.send(instanceConnection, { instance_id: instanceId });
|
||||||
this.instanceConnections.delete(instanceId);
|
this.instanceConnections.delete(instanceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user