MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / parameters

Method parameters

daemon/src/entity/instance/instance.ts:145–284  ·  view source on GitHub ↗
(cfg: any, persistence = true)

Source from the content-addressed store, hash-verified

143
144 // Pass in instance configuration, loosely and dynamically set configuration items for instance parameters
145 parameters(cfg: any, persistence = true) {
146 // If the instance type changes, default commands and lifecycle events must be reset
147 if (cfg?.type && cfg?.type != this.config.type) {
148 if (!this.isStoppedOrBusy())
149 throw new Error($t("TXT_CODE_instanceConf.cantModifyInstanceType"));
150 configureEntityParams(this.config, cfg, "type", String);
151 this.forceExec(new FunctionDispatcher());
152 }
153
154 if (cfg?.enableRcon != null && cfg?.enableRcon !== this.config.enableRcon) {
155 if (!this.isStoppedOrBusy()) throw new Error($t("TXT_CODE_bdfa3457"));
156 configureEntityParams(this.config, cfg, "enableRcon", Boolean);
157 this.forceExec(new FunctionDispatcher());
158 }
159
160 if (cfg?.processType && cfg?.processType !== this.config.processType) {
161 if (!this.isStoppedOrBusy())
162 throw new Error($t("TXT_CODE_instanceConf.cantModifyProcessType"));
163 configureEntityParams(this.config, cfg, "processType", String);
164 this.forceExec(new FunctionDispatcher());
165 }
166
167 // If the terminal type is changed, the default command must be reset
168 if (
169 cfg?.terminalOption?.pty != null &&
170 cfg?.terminalOption?.pty !== this.config.terminalOption.pty
171 ) {
172 if (!this.isStoppedOrBusy()) throw new Error($t("TXT_CODE_instanceConf.cantModifyPtyModel"));
173 configureEntityParams(this.config.terminalOption, cfg.terminalOption, "pty", Boolean);
174 this.forceExec(new FunctionDispatcher());
175 }
176
177 // Only allow some configuration items to be modified when the server is stopped
178 if (this.isStoppedOrBusy() && cfg.terminalOption) {
179 configureEntityParams(this.config.terminalOption, cfg.terminalOption, "ptyWindowCol", Number);
180 configureEntityParams(this.config.terminalOption, cfg.terminalOption, "ptyWindowRow", Number);
181 }
182
183 if (cfg.tag instanceof Array) {
184 cfg.tag = cfg.tag.map((tag: any) => String(tag).trim());
185 this.config.tag = cfg.tag;
186 }
187
188 if (cfg?.extraServiceConfig) {
189 configureEntityParams(
190 this.config.extraServiceConfig,
191 cfg.extraServiceConfig,
192 "isOpenFrp",
193 Boolean
194 );
195 configureEntityParams(
196 this.config.extraServiceConfig,
197 cfg.extraServiceConfig,
198 "openFrpToken",
199 String
200 );
201 configureEntityParams(
202 this.config.extraServiceConfig,

Callers 4

createInstanceMethod · 0.95
onStartMethod · 0.80
Instance_router.tsFile · 0.80

Calls 7

isStoppedOrBusyMethod · 0.95
forceExecMethod · 0.95
allocatePortMethod · 0.95
$tFunction · 0.90
commandStringToArrayFunction · 0.90
configureEntityParamsFunction · 0.85
storeMethod · 0.65

Tested by

no test coverage detected