fix(start-web): adiciona fallback de rebuild para better-sqlite3
This commit is contained in:
parent
e9ba1790fb
commit
24656afff3
1 changed files with 27 additions and 4 deletions
|
|
@ -91,14 +91,34 @@ try {
|
|||
} catch (error) {
|
||||
console.error("[start-web] better-sqlite3 load failed:", error?.message || error)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
||||
copy_fallback_binding() {
|
||||
local temp_dir="/tmp/bsql-fallback"
|
||||
rm -rf "$temp_dir"
|
||||
mkdir -p "$temp_dir"
|
||||
(
|
||||
cd "$temp_dir" &&
|
||||
npm install better-sqlite3@11.10.0 --build-from-source --no-save >/dev/null 2>&1
|
||||
) || {
|
||||
echo "[start-web] fallback npm install falhou"
|
||||
return 1
|
||||
}
|
||||
local src_pkg="$temp_dir/node_modules/better-sqlite3"
|
||||
local dest_pkg="/app/node_modules/.bun/better-sqlite3@11.10.0/node_modules/better-sqlite3"
|
||||
mkdir -p "$dest_pkg"
|
||||
cp -R "$src_pkg/"* "$dest_pkg/" || return 1
|
||||
echo "[start-web] fallback: pacote better-sqlite3 copiado para .bun store"
|
||||
return 0
|
||||
}
|
||||
|
||||
rebuild_and_repin_sqlite() {
|
||||
echo "[start-web] rebuilding better-sqlite3 para a runtime atual"
|
||||
npm rebuild better-sqlite3 --build-from-source >/dev/null 2>&1 || {
|
||||
echo "[start-web] rebuild falhou; continuando com bindings existentes" >&2
|
||||
echo "[start-web] rebuild falhou; tentando fallback" >&2
|
||||
copy_fallback_binding || echo "[start-web] fallback também falhou" >&2
|
||||
}
|
||||
node - <<'EOF'
|
||||
const fs = require("node:fs")
|
||||
|
|
@ -131,9 +151,12 @@ EOF
|
|||
else
|
||||
rebuild_and_repin_sqlite
|
||||
check_better_sqlite3 || {
|
||||
echo "[start-web] ERRO: better-sqlite3 inválido após rebuild" >&2
|
||||
echo "[start-web] ERRO: better-sqlite3 inválido após rebuild; tentando fallback"
|
||||
copy_fallback_binding && check_better_sqlite3 || {
|
||||
echo "[start-web] ERRO: better-sqlite3 continua inválido após fallback" >&2
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue