forked from mirror/MCSM-Daemon
refactor: instance update config api
This commit is contained in:
parent
2e15f2fa1d
commit
a46e6fc906
@ -44,3 +44,28 @@ export function configureEntityParams(self: any, args: any, key: string, typeFn?
|
||||
self[key] = v;
|
||||
}
|
||||
}
|
||||
|
||||
export function toText(v: any) {
|
||||
if (isEmpty(v)) return null;
|
||||
return String(v);
|
||||
}
|
||||
|
||||
export function toNumber(v: any) {
|
||||
if (isEmpty(v)) return null;
|
||||
if (isNaN(Number(v))) return null;
|
||||
return Number(v);
|
||||
}
|
||||
|
||||
export function toBoolean(v: any) {
|
||||
if (isEmpty(v)) return null;
|
||||
return Boolean(v);
|
||||
}
|
||||
|
||||
export function isEmpty(v: any) {
|
||||
return v === null || v === undefined;
|
||||
}
|
||||
|
||||
export function supposeValue(v: any, def: any = null) {
|
||||
if (isEmpty(v)) return def;
|
||||
return v;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ export default class OpenFrpTask implements ILifeCycleTask {
|
||||
public name: string = "openfrp";
|
||||
|
||||
async start(instance: Instance) {
|
||||
const { openFrpToken, openFrpTunnelId, isOpenFrp } = instance.config?.extraServiceConfig;
|
||||
const { openFrpToken, openFrpTunnelId } = instance.config?.extraServiceConfig;
|
||||
if (openFrpToken && openFrpTunnelId) {
|
||||
const frpProcess = new OpenFrp(openFrpToken, openFrpTunnelId);
|
||||
frpProcess.processWrapper.on("start", (pid) => {
|
||||
|
@ -67,7 +67,6 @@ export default class InstanceConfig {
|
||||
};
|
||||
|
||||
public extraServiceConfig = {
|
||||
isOpenFrp: false,
|
||||
openFrpTunnelId: "",
|
||||
openFrpToken: ""
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user