mirror of
https://git.sanhost.net/sanasol/hytale-f2p.git
synced 2026-02-26 06:41:47 -03:00
fix: Use wrapper script to ensure LD_PRELOAD is applied on Linux
Node.js spawn with detached:true may not properly pass environment variables on some systems. Using a bash wrapper script guarantees LD_PRELOAD is set before the game process starts. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -389,6 +389,11 @@ exec "$REAL_JAVA" "\${ARGS[@]}"
|
||||
}
|
||||
}
|
||||
|
||||
// Debug: log LD_PRELOAD before spawn
|
||||
if (process.platform === 'linux') {
|
||||
console.log(`Linux: LD_PRELOAD = ${env.LD_PRELOAD || '(not set)'}`);
|
||||
}
|
||||
|
||||
try {
|
||||
let spawnOptions = {
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
@@ -401,7 +406,26 @@ exec "$REAL_JAVA" "\${ARGS[@]}"
|
||||
spawnOptions.windowsHide = true;
|
||||
}
|
||||
|
||||
const child = spawn(clientPath, args, spawnOptions);
|
||||
// Linux: Use wrapper script to ensure LD_PRELOAD is definitely applied
|
||||
// This works around potential issues with detached spawn not inheriting env properly
|
||||
let actualClientPath = clientPath;
|
||||
let actualArgs = args;
|
||||
|
||||
if (process.platform === 'linux' && env.LD_PRELOAD) {
|
||||
const wrapperPath = path.join(path.dirname(clientPath), 'launcher-wrapper.sh');
|
||||
const wrapperScript = `#!/bin/bash
|
||||
# Auto-generated wrapper to ensure LD_PRELOAD is applied
|
||||
export LD_PRELOAD="${env.LD_PRELOAD}"
|
||||
exec "$@"
|
||||
`;
|
||||
fs.writeFileSync(wrapperPath, wrapperScript, { mode: 0o755 });
|
||||
console.log(`Linux: Created wrapper script at ${wrapperPath}`);
|
||||
|
||||
actualClientPath = wrapperPath;
|
||||
actualArgs = [clientPath, ...args];
|
||||
}
|
||||
|
||||
const child = spawn(actualClientPath, actualArgs, spawnOptions);
|
||||
|
||||
console.log(`Game process started with PID: ${child.pid}`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user