mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-24 08:23:12 +09:00
Rename master plugin onExit hook to onShutdown
Rename the onExit hook for master plugins to onShutdown to better reflect when it is invoked.
This commit is contained in:
1 parent
9507608e59
commit
61d92a6910
5 files changed
+8
-6
No files matched your search
+1
-1
@@ -127,7 +127,7 @@ class BaseMasterPlugin {
|
|||||||
/**
|
/**
|
||||||
* Called when the master server is shutting down
|
* Called when the master server is shutting down
|
||||||
*/
|
*/
|
||||||
async onExit() { }
|
async onShutdown() { }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -250,8 +250,8 @@ async function shutdown() {
|
|||||||
|
|
||||||
for (let [pluginName, masterPlugin] of masterPlugins) {
|
for (let [pluginName, masterPlugin] of masterPlugins) {
|
||||||
let startTime = Date.now();
|
let startTime = Date.now();
|
||||||
await masterPlugin.onExit();
|
await masterPlugin.onShutdown();
|
||||||
console.log(`Plugin ${pluginName} exited in ${Date.now() - startTime}ms`);
|
console.log(`Plugin ${pluginName} shutdown in ${Date.now() - startTime}ms`);
|
||||||
}
|
}
|
||||||
|
|
||||||
stopAcceptingNewSessions = true;
|
stopAcceptingNewSessions = true;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class MasterPlugin extends plugin.BaseMasterPlugin {
|
|||||||
this.progressToBroadcast = new Set();
|
this.progressToBroadcast = new Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
async onExit() {
|
async onShutdown() {
|
||||||
if (this.progressBroadcastId) {
|
if (this.progressBroadcastId) {
|
||||||
clearTimeout(this.progressBroadcastId);
|
clearTimeout(this.progressBroadcastId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ class MasterPlugin extends plugin.BaseMasterPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async onExit() {
|
async onShutdown() {
|
||||||
clearInterval(this.autosaveId);
|
clearInterval(this.autosaveId);
|
||||||
clearInterval(this.doleMagicId);
|
clearInterval(this.doleMagicId);
|
||||||
await saveDatabase(this.master.config, this.items);
|
await saveDatabase(this.master.config, this.items);
|
||||||
|
|||||||
+3
-1
@@ -16,6 +16,7 @@ describe("lib/plugin", function() {
|
|||||||
await instancePlugin.init();
|
await instancePlugin.init();
|
||||||
})
|
})
|
||||||
it("should define defaults for hooks", async function() {
|
it("should define defaults for hooks", async function() {
|
||||||
|
await instancePlugin.onMetrics();
|
||||||
await instancePlugin.onStart();
|
await instancePlugin.onStart();
|
||||||
await instancePlugin.onStop();
|
await instancePlugin.onStop();
|
||||||
instancePlugin.onExit();
|
instancePlugin.onExit();
|
||||||
@@ -30,7 +31,8 @@ describe("lib/plugin", function() {
|
|||||||
await masterPlugin.init();
|
await masterPlugin.init();
|
||||||
})
|
})
|
||||||
it("should define defaults for hooks", async function() {
|
it("should define defaults for hooks", async function() {
|
||||||
await masterPlugin.onExit();
|
await masterPlugin.onMetrics();
|
||||||
|
await masterPlugin.onShutdown();
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user