fix: handle stockfish process error, try /usr/games/stockfish path
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user