mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-24 16:23:12 +09:00
Show which config entries requires a restart
Add a label in the web UI to config entries that require a restart to take effect as this is not obvious to end users.
This commit is contained in:
1 parent
0af1a25c93
commit
8662243ed1
4 files changed
+80
-5
No files matched your search
@@ -677,6 +677,12 @@ class ConfigGroup {
|
|||||||
* @param {Array=} item.enum -
|
* @param {Array=} item.enum -
|
||||||
* Array of all values that are acceptible. Useful for making
|
* Array of all values that are acceptible. Useful for making
|
||||||
* enumerated values.
|
* enumerated values.
|
||||||
|
* @param {boolean=} item.restartRequired -
|
||||||
|
* True if a restart of the entity this config is attached to is
|
||||||
|
* required for changes to take effect. Informative only, defaults
|
||||||
|
* to false.
|
||||||
|
* @param {Array=} item.restartRequiredProps -
|
||||||
|
* Properties to invert the value of restartRequired for if present.
|
||||||
* @param {boolean=} item.optional -
|
* @param {boolean=} item.optional -
|
||||||
* True if this field can be set to null. Defaults to false.
|
* True if this field can be set to null. Defaults to false.
|
||||||
* @param {*=} item.initial_value -
|
* @param {*=} item.initial_value -
|
||||||
@@ -706,6 +712,7 @@ class ConfigGroup {
|
|||||||
|
|
||||||
// Validate properties
|
// Validate properties
|
||||||
let validTypes = ["boolean", "string", "number", "object"];
|
let validTypes = ["boolean", "string", "number", "object"];
|
||||||
|
// eslint-disable-next-line complexity
|
||||||
Object.keys(item).forEach(key => {
|
Object.keys(item).forEach(key => {
|
||||||
let value = item[key];
|
let value = item[key];
|
||||||
let valueType = basicType(value);
|
let valueType = basicType(value);
|
||||||
@@ -746,6 +753,18 @@ class ConfigGroup {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "restartRequired":
|
||||||
|
if (valueType !== "boolean") {
|
||||||
|
throw new Error("restartRequired must be a boolean");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "restartRequiredProps":
|
||||||
|
if (valueType !== "array") {
|
||||||
|
throw new Error("restartRequiredProps must be a array");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case "optional":
|
case "optional":
|
||||||
if (valueType !== "boolean") {
|
if (valueType !== "boolean") {
|
||||||
throw new Error("optional must be a boolean");
|
throw new Error("optional must be a boolean");
|
||||||
@@ -771,9 +790,14 @@ class ConfigGroup {
|
|||||||
access: this.defaultAccess,
|
access: this.defaultAccess,
|
||||||
optional: false,
|
optional: false,
|
||||||
fullName: `${this.groupName}.${item.name}`,
|
fullName: `${this.groupName}.${item.name}`,
|
||||||
|
restartRequired: false,
|
||||||
...item,
|
...item,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (item.restartRequiredProps && item.type !== "object") {
|
||||||
|
throw new Error("restartRequiredProps is only allowed if type is object");
|
||||||
|
}
|
||||||
|
|
||||||
if (!computed.access) {
|
if (!computed.access) {
|
||||||
throw new Error(`access not set and no defaultAccess defined for ${this.name}`);
|
throw new Error(`access not set and no defaultAccess defined for ${this.name}`);
|
||||||
}
|
}
|
||||||
@@ -815,6 +839,7 @@ class PluginConfigGroup extends ConfigGroup {
|
|||||||
this.define({
|
this.define({
|
||||||
name: "load_plugin",
|
name: "load_plugin",
|
||||||
title: "Load Plugin",
|
title: "Load Plugin",
|
||||||
|
restartRequired: true,
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
initial_value: true,
|
initial_value: true,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ MasterGroup.define({
|
|||||||
name: "http_port",
|
name: "http_port",
|
||||||
title: "HTTP Port",
|
title: "HTTP Port",
|
||||||
description: "Port to listen for HTTP connections on, set to null to not listen for HTTP connections.",
|
description: "Port to listen for HTTP connections on, set to null to not listen for HTTP connections.",
|
||||||
|
restartRequired: true,
|
||||||
type: "number",
|
type: "number",
|
||||||
optional: true,
|
optional: true,
|
||||||
initial_value: 8080,
|
initial_value: 8080,
|
||||||
@@ -45,6 +46,7 @@ MasterGroup.define({
|
|||||||
name: "https_port",
|
name: "https_port",
|
||||||
title: "HTTPS Port",
|
title: "HTTPS Port",
|
||||||
description: "Port to listen for HTTPS connection on, set to null to not listen for HTTPS connections.",
|
description: "Port to listen for HTTPS connection on, set to null to not listen for HTTPS connections.",
|
||||||
|
restartRequired: true,
|
||||||
type: "number",
|
type: "number",
|
||||||
optional: true,
|
optional: true,
|
||||||
});
|
});
|
||||||
@@ -52,6 +54,7 @@ MasterGroup.define({
|
|||||||
name: "bind_address",
|
name: "bind_address",
|
||||||
title: "Bind Address",
|
title: "Bind Address",
|
||||||
description: "IP address to bind the HTTP and HTTPS ports on.",
|
description: "IP address to bind the HTTP and HTTPS ports on.",
|
||||||
|
restartRequired: true,
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: true,
|
optional: true,
|
||||||
});
|
});
|
||||||
@@ -66,6 +69,7 @@ MasterGroup.define({
|
|||||||
name: "tls_certificate",
|
name: "tls_certificate",
|
||||||
title: "TLS Certificate",
|
title: "TLS Certificate",
|
||||||
description: "Path to the certificate to use for HTTPS.",
|
description: "Path to the certificate to use for HTTPS.",
|
||||||
|
restartRequired: true,
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: true,
|
optional: true,
|
||||||
});
|
});
|
||||||
@@ -73,6 +77,7 @@ MasterGroup.define({
|
|||||||
name: "tls_private_key",
|
name: "tls_private_key",
|
||||||
title: "TLS Private Key",
|
title: "TLS Private Key",
|
||||||
description: "Path to the private key to use for HTTPS.",
|
description: "Path to the private key to use for HTTPS.",
|
||||||
|
restartRequired: true,
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: true,
|
optional: true,
|
||||||
});
|
});
|
||||||
@@ -84,6 +89,7 @@ MasterGroup.define({
|
|||||||
"Secret used to generate and verify authentication tokens. " +
|
"Secret used to generate and verify authentication tokens. " +
|
||||||
"Should be a long string of random letters and numbers. " +
|
"Should be a long string of random letters and numbers. " +
|
||||||
"Do not share this.",
|
"Do not share this.",
|
||||||
|
restartRequired: true,
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: true,
|
optional: true,
|
||||||
});
|
});
|
||||||
@@ -184,24 +190,28 @@ SlaveGroup.define({
|
|||||||
SlaveGroup.define({
|
SlaveGroup.define({
|
||||||
name: "instances_directory",
|
name: "instances_directory",
|
||||||
description: "Path to directory to store instances in.",
|
description: "Path to directory to store instances in.",
|
||||||
|
restartRequired: true,
|
||||||
type: "string",
|
type: "string",
|
||||||
initial_value: "instances",
|
initial_value: "instances",
|
||||||
});
|
});
|
||||||
SlaveGroup.define({
|
SlaveGroup.define({
|
||||||
name: "master_url",
|
name: "master_url",
|
||||||
description: "URL to connect to the master server at",
|
description: "URL to connect to the master server at",
|
||||||
|
restartRequired: true,
|
||||||
type: "string",
|
type: "string",
|
||||||
initial_value: "http://localhost:8080/",
|
initial_value: "http://localhost:8080/",
|
||||||
});
|
});
|
||||||
SlaveGroup.define({
|
SlaveGroup.define({
|
||||||
name: "master_token",
|
name: "master_token",
|
||||||
description: "Token to authenticate to master server with.",
|
description: "Token to authenticate to master server with.",
|
||||||
|
restartRequired: true,
|
||||||
type: "string",
|
type: "string",
|
||||||
initial_value: "enter token here",
|
initial_value: "enter token here",
|
||||||
});
|
});
|
||||||
SlaveGroup.define({
|
SlaveGroup.define({
|
||||||
name: "tls_ca",
|
name: "tls_ca",
|
||||||
description: "Path to Certificate Authority to validate TLS connection to master against.",
|
description: "Path to Certificate Authority to validate TLS connection to master against.",
|
||||||
|
restartRequired: true,
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: true,
|
optional: true,
|
||||||
});
|
});
|
||||||
@@ -244,7 +254,7 @@ InstanceGroup.define({
|
|||||||
});
|
});
|
||||||
InstanceGroup.define({
|
InstanceGroup.define({
|
||||||
name: "id",
|
name: "id",
|
||||||
description: "ID of the slave",
|
description: "ID of the instance",
|
||||||
type: "number",
|
type: "number",
|
||||||
initial_value: () => Math.random() * 2**31 | 0,
|
initial_value: () => Math.random() * 2**31 | 0,
|
||||||
});
|
});
|
||||||
@@ -272,24 +282,28 @@ FactorioGroup.groupName = "factorio";
|
|||||||
FactorioGroup.define({
|
FactorioGroup.define({
|
||||||
name: "version",
|
name: "version",
|
||||||
description: "Version of the game to run, use latest to run the latest installed version",
|
description: "Version of the game to run, use latest to run the latest installed version",
|
||||||
|
restartRequired: true,
|
||||||
type: "string",
|
type: "string",
|
||||||
initial_value: "latest",
|
initial_value: "latest",
|
||||||
});
|
});
|
||||||
FactorioGroup.define({
|
FactorioGroup.define({
|
||||||
name: "game_port",
|
name: "game_port",
|
||||||
description: "UDP port to run game on, uses a random port if null",
|
description: "UDP port to run game on, uses a random port if null",
|
||||||
|
restartRequired: true,
|
||||||
type: "number",
|
type: "number",
|
||||||
optional: true,
|
optional: true,
|
||||||
});
|
});
|
||||||
FactorioGroup.define({
|
FactorioGroup.define({
|
||||||
name: "rcon_port",
|
name: "rcon_port",
|
||||||
description: "TCP port to run RCON on, uses a random port if null",
|
description: "TCP port to run RCON on, uses a random port if null",
|
||||||
|
restartRequired: true,
|
||||||
type: "number",
|
type: "number",
|
||||||
optional: true,
|
optional: true,
|
||||||
});
|
});
|
||||||
FactorioGroup.define({
|
FactorioGroup.define({
|
||||||
name: "rcon_password",
|
name: "rcon_password",
|
||||||
description: "Password for RCON, randomly generated if null",
|
description: "Password for RCON, randomly generated if null",
|
||||||
|
restartRequired: true,
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: true,
|
optional: true,
|
||||||
});
|
});
|
||||||
@@ -304,12 +318,14 @@ FactorioGroup.define({
|
|||||||
FactorioGroup.define({
|
FactorioGroup.define({
|
||||||
name: "mod_pack",
|
name: "mod_pack",
|
||||||
description: "Mod pack to use on this server",
|
description: "Mod pack to use on this server",
|
||||||
|
restartRequired: true,
|
||||||
type: "number",
|
type: "number",
|
||||||
optional: true,
|
optional: true,
|
||||||
});
|
});
|
||||||
FactorioGroup.define({
|
FactorioGroup.define({
|
||||||
name: "enable_save_patching",
|
name: "enable_save_patching",
|
||||||
description: "Patch saves with Lua code. Required for Clusterio integrations, lua modules, and most plugins.",
|
description: "Patch saves with Lua code. Required for Clusterio integrations, lua modules, and most plugins.",
|
||||||
|
restartRequired: true,
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
initial_value: true,
|
initial_value: true,
|
||||||
});
|
});
|
||||||
@@ -322,24 +338,34 @@ FactorioGroup.define({
|
|||||||
FactorioGroup.define({
|
FactorioGroup.define({
|
||||||
name: "enable_authserver_bans",
|
name: "enable_authserver_bans",
|
||||||
description: "Turn on Factorio.com based multiplayer bans.",
|
description: "Turn on Factorio.com based multiplayer bans.",
|
||||||
|
restartRequired: true,
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
initial_value: false,
|
initial_value: false,
|
||||||
});
|
});
|
||||||
FactorioGroup.define({
|
FactorioGroup.define({
|
||||||
name: "settings",
|
name: "settings",
|
||||||
description: "Settings overridden in server-settings.json",
|
description: "Settings overridden in server-settings.json",
|
||||||
|
restartRequired: true,
|
||||||
|
restartRequiredProps: [
|
||||||
|
"afk_autokick_interval", "allow_commands", "autosave_interval", "autosave_only_on_server", "description",
|
||||||
|
"ignore_player_limit_for_returning_players", "max_players", "max_upload_slots",
|
||||||
|
"max_upload_in_kilobytes_per_second", "name", "only_admins_can_pause_the_game", "game_password",
|
||||||
|
"require_user_verification", "tags", "visibility",
|
||||||
|
],
|
||||||
type: "object",
|
type: "object",
|
||||||
initial_value: {}, // See create instance handler in master.
|
initial_value: {}, // See create instance handler in master.
|
||||||
});
|
});
|
||||||
FactorioGroup.define({
|
FactorioGroup.define({
|
||||||
name: "verbose_logging",
|
name: "verbose_logging",
|
||||||
description: "Enable verbose logging on the Factorio server",
|
description: "Enable verbose logging on the Factorio server",
|
||||||
|
restartRequired: true,
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
initial_value: false,
|
initial_value: false,
|
||||||
});
|
});
|
||||||
FactorioGroup.define({
|
FactorioGroup.define({
|
||||||
name: "strip_paths",
|
name: "strip_paths",
|
||||||
description: "Strip down instance paths in the log",
|
description: "Strip down instance paths in the log",
|
||||||
|
restartRequired: true,
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
initial_value: true,
|
initial_value: true,
|
||||||
});
|
});
|
||||||
@@ -364,6 +390,7 @@ FactorioGroup.define({
|
|||||||
FactorioGroup.define({
|
FactorioGroup.define({
|
||||||
name: "max_concurrent_commands",
|
name: "max_concurrent_commands",
|
||||||
description: "Maximum number of RCON commands trasmitted in parallel",
|
description: "Maximum number of RCON commands trasmitted in parallel",
|
||||||
|
restartRequired: true,
|
||||||
type: "number",
|
type: "number",
|
||||||
initial_value: 5,
|
initial_value: 5,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Button, Card, Checkbox, Form, Input, InputNumber, Space, Spin, Tree, Typography } from "antd";
|
import { Button, Card, Checkbox, Form, Input, InputNumber, Space, Spin, Tooltip, Tree, Typography } from "antd";
|
||||||
|
import ReloadOutlined from "@ant-design/icons/ReloadOutlined";
|
||||||
|
|
||||||
const { Title } = Typography;
|
const { Title } = Typography;
|
||||||
|
|
||||||
@@ -87,6 +88,11 @@ export default function BaseConfigTree(props) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let restartTip = <Tooltip
|
||||||
|
className="ant-form-item-tooltip"
|
||||||
|
title="A restart is required for this setting to take effect"
|
||||||
|
><ReloadOutlined/></Tooltip>;
|
||||||
|
|
||||||
let treeData = [];
|
let treeData = [];
|
||||||
let propsMap = new Map();
|
let propsMap = new Map();
|
||||||
for (let [name, GroupClass] of props.ConfigClass.groups) {
|
for (let [name, GroupClass] of props.ConfigClass.groups) {
|
||||||
@@ -110,14 +116,27 @@ export default function BaseConfigTree(props) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (def.type === "object") {
|
if (def.type === "object") {
|
||||||
childNode.title = <Form.Item label={def.title || def.name} tooltip={def.description} />;
|
let restartRequiredProps = new Set(def.restartRequiredProps || []);
|
||||||
|
childNode.title = <Form.Item
|
||||||
|
label={<>
|
||||||
|
{def.title || def.name}
|
||||||
|
{!def.restartRequiredProps && def.restartRequired && restartTip}
|
||||||
|
</>}
|
||||||
|
tooltip={def.description}
|
||||||
|
/>;
|
||||||
for (let prop of Object.keys(value)) {
|
for (let prop of Object.keys(value)) {
|
||||||
let propPath = `${group.name}.${def.name}.${prop}`;
|
let propPath = `${group.name}.${def.name}.${prop}`;
|
||||||
|
let restart = Boolean(
|
||||||
|
def.restartRequiredProps && def.restartRequired ^ restartRequiredProps.has(prop)
|
||||||
|
);
|
||||||
childNode.children.push({
|
childNode.children.push({
|
||||||
key: propPath,
|
key: propPath,
|
||||||
title: <Form.Item
|
title: <Form.Item
|
||||||
name={propPath}
|
name={propPath}
|
||||||
label={`"${prop}"`}
|
label={<>
|
||||||
|
{`"${prop}"`}
|
||||||
|
{restart && restartTip}
|
||||||
|
</>}
|
||||||
rules={[{ validator: (_, fieldValue) => {
|
rules={[{ validator: (_, fieldValue) => {
|
||||||
if (!fieldValue.length) {
|
if (!fieldValue.length) {
|
||||||
return Promise.reject(new Error("Will be removed"));
|
return Promise.reject(new Error("Will be removed"));
|
||||||
@@ -184,7 +203,10 @@ export default function BaseConfigTree(props) {
|
|||||||
} else {
|
} else {
|
||||||
childNode.title = <Form.Item
|
childNode.title = <Form.Item
|
||||||
name={fieldName}
|
name={fieldName}
|
||||||
label={def.title || def.name}
|
label={<>
|
||||||
|
{def.title || def.name}
|
||||||
|
{def.restartRequired && restartTip}
|
||||||
|
</>}
|
||||||
validateStatus={errorFields.has(fieldName) ? "error" : undefined}
|
validateStatus={errorFields.has(fieldName) ? "error" : undefined}
|
||||||
help={errorFields.get(fieldName)}
|
help={errorFields.get(fieldName)}
|
||||||
tooltip={def.description}
|
tooltip={def.description}
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ describe("lib/config/classes", function() {
|
|||||||
name: "enum",
|
name: "enum",
|
||||||
title: "Enum",
|
title: "Enum",
|
||||||
description: "Enum thingy",
|
description: "Enum thingy",
|
||||||
|
restartRequired: true,
|
||||||
enum: ["a", "b", "c"],
|
enum: ["a", "b", "c"],
|
||||||
optional: true,
|
optional: true,
|
||||||
initial_value: "b",
|
initial_value: "b",
|
||||||
|
|||||||
Reference in new issue
Block a user