Reewrite project #430
@ -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") {
|
||||
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\"");
|
||||
}
|
||||
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};
|
||||
}
|
@ -1,19 +1,12 @@
|
||||
import { installServer, startServer } from "../src/bedrock";
|
||||
|
||||
describe("Bedrock", () => {
|
||||
it("Install", async function(){
|
||||
it("Install and Start", async function(){
|
||||
this.timeout(1000*60*60*15);
|
||||
return installServer(true);
|
||||
});
|
||||
after(async () => {
|
||||
describe("After bedrock", async () => {
|
||||
it("Start Server", async function() {
|
||||
this.timeout(1000*60*60*15);
|
||||
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))));
|
||||
});
|
||||
});
|
||||
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))));
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user