-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloader.js
36 lines (27 loc) · 1.16 KB
/
loader.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const child_process = require("child_process");
// Add your files here
const start_files = [
"./Bot1/index.js",
"./Bot2/index.js"
];
// Don't edit below this line
console.log(`[Loader]Loading ${start_files.length} files`);
function runfile(name) {
return new Promise((resolve) => {
const working_dir = name.split("/").slice(0, -1).join("/");
const file = name.split("/")[name.split("/").length - 1];
console.log(`[Loader]Installing dependencies in directory ${working_dir}`);
child_process.spawn("npm", [ "install", "--build-from-resource", "--no-bin-links", "--cache", "/tmp/.npm-global", "--update-notifier", "false", "--prefix", `/home/minecraft/multicraft/servers/server${process.env.SERVER_ID}/${working_dir}` ], {
cwd: working_dir
}).on("exit", () => {
console.log(`[Loader]Opening file ${name}`);
child_process.spawn(process.execPath, [ file ], {
cwd: working_dir,
stdio: 'inherit'
}).on("exit", resolve);
});
});
}
for (const f of start_files) {
runfile(f).then(() => console.log(`[Loader]File ${f} stopped`));
}