Add Node.js manager service and updated docker-compose
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import YAML from "yaml";
|
||||
|
||||
export interface InstanceConfig {
|
||||
id: string;
|
||||
containerName: string;
|
||||
image: string;
|
||||
savedDir: string;
|
||||
configPaths: {
|
||||
serverDescription: string;
|
||||
worldsRoot: string;
|
||||
};
|
||||
}
|
||||
|
||||
const CONFIG_PATH = path.join(__dirname, "..", "..", "config", "instances.yml");
|
||||
|
||||
let cache: { instances: InstanceConfig[] };
|
||||
|
||||
export function loadConfig() {
|
||||
if (!cache) {
|
||||
const raw = fs.readFileSync(CONFIG_PATH, "utf8");
|
||||
cache = YAML.parse(raw);
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
|
||||
export function getInstance(id: string) {
|
||||
return loadConfig().instances.find(i => i.id === id);
|
||||
}
|
||||
Reference in New Issue
Block a user