changed server2 user_profile.db to remove sqlite connection
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
This commit is contained in:
parent
8cfcd2e2d7
commit
6578d3c856
@ -503,17 +503,18 @@ let userProfileDb;
|
|||||||
|
|
||||||
async function initDatabases() {
|
async function initDatabases() {
|
||||||
try {
|
try {
|
||||||
|
// Open salary DB as an immutable, read-only URI so SQLite never touches -wal/-shm/-journal.
|
||||||
|
// Requires OPEN_URI flag in addition to OPEN_READONLY.
|
||||||
|
const SALARY_DB_URI = `file:${SALARY_DB_PATH}?immutable=1&mode=ro`;
|
||||||
dbSqlite = await open({
|
dbSqlite = await open({
|
||||||
filename: SALARY_DB_PATH,
|
filename: SALARY_DB_URI,
|
||||||
driver : sqlite3.Database,
|
driver : sqlite3.Database,
|
||||||
mode : sqlite3.OPEN_READONLY
|
mode : sqlite3.OPEN_READONLY | sqlite3.OPEN_URI
|
||||||
});
|
});
|
||||||
console.log('✅ Connected to salary_info.db');
|
console.log('✅ Connected to salary_info.db (immutable, ro)');
|
||||||
// Light PRAGMAs safe for read-only workload
|
// Read-only safe PRAGMAs (no write state). journal_mode/synchronous removed.
|
||||||
await dbSqlite.exec(`
|
await dbSqlite.exec(`
|
||||||
PRAGMA busy_timeout=4000;
|
PRAGMA busy_timeout=4000;
|
||||||
PRAGMA journal_mode=OFF;
|
|
||||||
PRAGMA synchronous=OFF;
|
|
||||||
PRAGMA temp_store=MEMORY;
|
PRAGMA temp_store=MEMORY;
|
||||||
`);
|
`);
|
||||||
// One prepared statement: regional (param) + national in a single scan
|
// One prepared statement: regional (param) + national in a single scan
|
||||||
@ -534,11 +535,18 @@ async function initDatabases() {
|
|||||||
AND (AREA_TITLE = ? OR AREA_TITLE = 'U.S.')
|
AND (AREA_TITLE = ? OR AREA_TITLE = 'U.S.')
|
||||||
`);
|
`);
|
||||||
|
|
||||||
|
// In prod, user_profile is MySQL; do not try to open a SQLite file here.
|
||||||
|
// Leave dev behavior untouched: only open SQLite if clearly running non-prod.
|
||||||
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
userProfileDb = await open({
|
userProfileDb = await open({
|
||||||
filename: USER_PROFILE_DB_PATH,
|
filename: USER_PROFILE_DB_PATH,
|
||||||
driver : sqlite3.Database
|
driver : sqlite3.Database
|
||||||
});
|
});
|
||||||
console.log('✅ Connected to user_profile.db');
|
console.log('✅ Connected to user_profile.db (sqlite, dev)');
|
||||||
|
} else {
|
||||||
|
userProfileDb = null;
|
||||||
|
console.log('ℹ️ user_profile via MySQL pool (no SQLite open in prod)');
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('❌ DB init failed →', err);
|
console.error('❌ DB init failed →', err);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user