添加初始化页面

This commit is contained in:
CN-JS-HuiBai
2026-04-04 16:53:41 +08:00
parent e69424dab2
commit c6c3dd2134
4 changed files with 349 additions and 11 deletions

View File

@@ -1,14 +1,26 @@
const mysql = require('mysql2/promise');
const pool = mysql.createPool({
host: process.env.MYSQL_HOST || 'localhost',
port: parseInt(process.env.MYSQL_PORT) || 3306,
user: process.env.MYSQL_USER || 'root',
password: process.env.MYSQL_PASSWORD || '',
database: process.env.MYSQL_DATABASE || 'display_wall',
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0
});
let pool;
module.exports = pool;
function initPool() {
if (pool) {
pool.end().catch(e => console.error('Error closing pool:', e));
}
pool = mysql.createPool({
host: process.env.MYSQL_HOST || 'localhost',
port: parseInt(process.env.MYSQL_PORT) || 3306,
user: process.env.MYSQL_USER || 'root',
password: process.env.MYSQL_PASSWORD || '',
database: process.env.MYSQL_DATABASE || 'display_wall',
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0
});
}
initPool();
module.exports = {
query: (...args) => pool.query(...args),
initPool
};