Reewrite project #430

Merged
Sirherobrine23 merged 13 commits from reewriteProject into main 2022-08-31 10:03:14 +00:00
2 changed files with 13 additions and 22 deletions
Showing only changes of commit 7f92770822 - Show all commits

View File

@ -77,18 +77,16 @@ const serverConfig: actionConfig[] = [
export async function startServer() {
if (!fsOld.existsSync(serverPath)) throw new Error("Install server fist");
let command = path.join(serverPath, "bedrock_server");
const args: string[] = [];
if (process.platform === "linux") {
if (process.arch !== "x64") {
let command = path.join(serverPath, "bedrock_server");
if (process.platform === "linux" && process.arch !== "x64") {
args.push(command);
if (await execAsync("command -v qemu-x86_64-static").then(() => true).catch(() => false)) command = "qemu-x86_64-static";
else if (await execAsync("command -v box64").then(() => true).catch(() => false)) command = "box64";
else throw new Error("Cannot emulate x64 architecture. Check the documentents in \"https://github.com/The-Bds-Maneger/Bds-Maneger-Core/wiki/Server-Platforms#minecraft-bedrock-server-alpha\"");
}
}
const serverProcess = exec(command, args, {cwd: serverPath, maxBuffer: Infinity, env: {LD_LIBRARY_PATH: process.platform !== "win32" ? serverPath:undefined}});
const serverProcess = exec(command, args, {cwd: serverPath, maxBuffer: Infinity, env: {LD_LIBRARY_PATH: process.platform === "win32"?undefined:serverPath}});
const serverActions = new actions(serverProcess, serverConfig);
return {serverProcess, serverActions};
}

View File

@ -1,19 +1,12 @@
import { installServer, startServer } from "../src/bedrock";
describe("Bedrock", () => {
it("Install", async function(){
this.timeout(1000*60*60*15);
return installServer(true);
});
after(async () => {
describe("After bedrock", async () => {
it("Start Server", async function() {
it("Install and Start", async function(){
this.timeout(1000*60*60*15);
await installServer(true);
const serverManeger = await startServer();
serverManeger.serverProcess.on("stdoutRaw", data => process.stdout.write(data));
serverManeger.serverActions.once("serverStarted", () => serverManeger.serverProcess.writeStdin("stop"));
return new Promise((done, reject) => serverManeger.serverProcess.on("close", ({code}) => code === 0?done():reject(new Error("Exit another code "+code))));
});
});
});
});