mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 15:43:13 +09:00
Add instance config event for master plugins
Add onInstanceConfigFieldChanged hook for master plugin code which triggers when instance configs are changed on the master server.
This commit is contained in:
1 parent
8b857224dc
commit
322570f298
4 files changed
+28
-1
No files matched your search
@@ -151,6 +151,10 @@ class Master {
|
||||
this.userManager = new UserManager(this.config);
|
||||
await this.userManager.load(path.join(databaseDirectory, "users.json"));
|
||||
|
||||
for (let instance of this.instances.values()) {
|
||||
this.addInstancePluginHooks(instance);
|
||||
}
|
||||
|
||||
// Make sure we're actually going to listen on a port
|
||||
let httpPort = this.config.get("master.http_port");
|
||||
let httpsPort = this.config.get("master.https_port");
|
||||
@@ -305,7 +309,8 @@ class Master {
|
||||
let instanceConfig = new libConfig.InstanceConfig("master");
|
||||
await instanceConfig.load(serializedConfig);
|
||||
let status = instanceConfig.get("instance.assigned_slave") === null ? "unassigned" : "unknown";
|
||||
instances.set(instanceConfig.get("instance.id"), { config: instanceConfig, status });
|
||||
let instance = { config: instanceConfig, status };
|
||||
instances.set(instanceConfig.get("instance.id"), instance);
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
@@ -356,6 +361,12 @@ class Master {
|
||||
}
|
||||
}
|
||||
|
||||
addInstancePluginHooks(instance) {
|
||||
instance.config.on("fieldChanged", (group, field, prev) => {
|
||||
libPlugin.invokeHook(this.plugins, "onInstanceConfigFieldChanged", instance, group, field, prev);
|
||||
});
|
||||
}
|
||||
|
||||
async loadPlugins() {
|
||||
for (let pluginInfo of this.pluginInfos) {
|
||||
if (!this.config.group(pluginInfo.name).get("load_plugin")) {
|
||||
|
||||
Reference in new issue
Block a user