fix: handle stockfish process error, try /usr/games/stockfish path

This commit is contained in:
Michess
2026-04-13 14:19:58 +02:00
parent 157fcf8fa4
commit 4bc6ea58e6

View File

@@ -30,10 +30,21 @@ export class StockfishEngine {
private async init() {
try {
this.process = spawn("stockfish", [], {
// Debian installs stockfish to /usr/games/stockfish
const sfBin = ["/usr/games/stockfish", "/usr/bin/stockfish", "stockfish"]
.find(p => { try { require("fs").accessSync(p); return true; } catch { return false; } })
?? "stockfish";
this.process = spawn(sfBin, [], {
stdio: ["pipe", "pipe", "pipe"],
});
this.process.on("error", (err) => {
console.error("Stockfish process error:", err.message);
this.process = null;
this.ready = false;
});
await new Promise<void>((resolve) => {
let readyOk = false;