mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-18 23:33:12 +09:00
Don't try stopping if instance is already stopped (#401)
Ignore stop if instance status is already stopped. Fixes instance status getting stuck at stopping if Factorio exits during startup due to the stopped status having already been sent at the time stop is invoked. Fixes #400
This commit is contained in:
1 parent
dbe623c9a7
commit
f2c9cd0c62
2 files changed
+16
-6
No files matched your search
@@ -168,8 +168,8 @@ class Instance extends libLink.Link {
|
||||
maxConcurrentCommands: this.config.get("factorio.max_concurrent_commands"),
|
||||
};
|
||||
|
||||
// Valid statuses are stopped, starting, running, stopping, creating_save and exporting_data.
|
||||
this._status = "stopped";
|
||||
this._running = false;
|
||||
this._loadedSave = null;
|
||||
this.server = new libFactorio.FactorioServer(
|
||||
factorioDir, this._dir, serverOptions
|
||||
@@ -276,7 +276,6 @@ class Instance extends libLink.Link {
|
||||
}
|
||||
|
||||
notifyExit() {
|
||||
this._running = false;
|
||||
this._loadedSave = null;
|
||||
this.notifyStatus("stopped");
|
||||
|
||||
@@ -577,7 +576,6 @@ class Instance extends libLink.Link {
|
||||
await this.sendSaveListUpdate();
|
||||
await libPlugin.invokeHook(this.plugins, "onStart");
|
||||
|
||||
this._running = true;
|
||||
this.notifyStatus("running");
|
||||
}
|
||||
|
||||
@@ -602,7 +600,6 @@ class Instance extends libLink.Link {
|
||||
|
||||
await libPlugin.invokeHook(this.plugins, "onStart");
|
||||
|
||||
this._running = true;
|
||||
this.notifyStatus("running");
|
||||
}
|
||||
|
||||
@@ -683,7 +680,9 @@ class Instance extends libLink.Link {
|
||||
* Stop the instance
|
||||
*/
|
||||
async stop() {
|
||||
this._running = false;
|
||||
if (this._status === "stopped") {
|
||||
return;
|
||||
}
|
||||
this.notifyStatus("stopping");
|
||||
|
||||
// XXX this needs more thought to it
|
||||
@@ -703,7 +702,7 @@ class Instance extends libLink.Link {
|
||||
|
||||
async getMetricsRequestHandler() {
|
||||
let results = [];
|
||||
if (this._running) {
|
||||
if (!["stopped", "stopping"].includes(this._status)) {
|
||||
let pluginResults = await libPlugin.invokeHook(this.plugins, "onMetrics");
|
||||
for (let metricIterator of pluginResults) {
|
||||
for await (let metric of metricIterator) {
|
||||
|
||||
Reference in new issue
Block a user