Implement kill instance

Add ability to kill running instances in case it is desirable to stop
the server without saving over the current save file.
This commit is contained in:
Hornwitser committed 2022-03-25 20:52:31 +01:00
1 parent a93f048814
commit 1e4d709a06
8 files changed
+186 -90

No files matched your search

+16 -1
View File
@@ -186,7 +186,11 @@ class Instance extends libLink.Link {
});
this.server.on("error", err => {
this.logger.error(`Error in instance ${this.name}:\n${err.stack}`);
if (err instanceof libErrors.EnvironmentError) {
this.logger.error(err.message);
} else {
this.logger.error(`${this.name}:\n${err.stack}`);
}
});
this.server.on("autosave-finished", name => {
@@ -697,6 +701,13 @@ class Instance extends libLink.Link {
}
}
async kill() {
if (this._status === "stopped") {
return;
}
await this.server.kill(true);
}
async masterConnectionEventEventHandler(message) {
await libPlugin.invokeHook(this.plugins, "onMasterConnectionEvent", message.data.event);
}
@@ -833,6 +844,10 @@ class Instance extends libLink.Link {
await this.stop();
}
async killInstanceRequestHandler() {
await this.kill();
}
async sendRconRequestHandler(message) {
let result = await this.sendRcon(message.data.command);
return { result };