자산관리 시스템 도커라이징
This commit is contained in:
47
server.js
47
server.js
@@ -4,7 +4,22 @@ import cors from 'cors';
|
||||
import dotenv from 'dotenv';
|
||||
import fs from 'fs';
|
||||
|
||||
dotenv.config({ override: true });
|
||||
dotenv.config();
|
||||
|
||||
const dbConfig = {
|
||||
host: process.env.DB_HOST,
|
||||
user: process.env.DB_USER,
|
||||
password: process.env.DB_PASS,
|
||||
database: process.env.DB_NAME,
|
||||
port: parseInt(process.env.DB_PORT || '3306')
|
||||
};
|
||||
|
||||
const getDbConnectionSummary = () => ({
|
||||
host: dbConfig.host || '(missing)',
|
||||
port: dbConfig.port,
|
||||
user: dbConfig.user || '(missing)',
|
||||
database: dbConfig.database || '(missing)'
|
||||
});
|
||||
|
||||
const app = express();
|
||||
app.use(cors());
|
||||
@@ -18,11 +33,11 @@ if (!fs.existsSync('uploads')) {
|
||||
|
||||
// MySQL Pool Configuration
|
||||
const pool = mysql.createPool({
|
||||
host: process.env.DB_HOST,
|
||||
user: process.env.DB_USER,
|
||||
password: process.env.DB_PASS,
|
||||
database: process.env.DB_NAME,
|
||||
port: parseInt(process.env.DB_PORT || '3306'),
|
||||
host: dbConfig.host,
|
||||
user: dbConfig.user,
|
||||
password: dbConfig.password,
|
||||
database: dbConfig.database,
|
||||
port: dbConfig.port,
|
||||
waitForConnections: true,
|
||||
connectionLimit: 10,
|
||||
queueLimit: 0
|
||||
@@ -48,7 +63,15 @@ const pool = mysql.createPool({
|
||||
`);
|
||||
console.log('✅ job_spec_standards table verification completed.');
|
||||
} catch (err) {
|
||||
console.error('❌ Failed to verify/create job_spec_standards table:', err);
|
||||
console.error('❌ Failed to verify/create job_spec_standards table:', {
|
||||
db: getDbConnectionSummary(),
|
||||
code: err.code,
|
||||
errno: err.errno,
|
||||
syscall: err.syscall,
|
||||
address: err.address,
|
||||
port: err.port,
|
||||
message: err.message
|
||||
});
|
||||
} finally {
|
||||
if (connection) connection.release();
|
||||
}
|
||||
@@ -56,7 +79,15 @@ const pool = mysql.createPool({
|
||||
|
||||
// Error Handler
|
||||
const handleError = (res, err, label) => {
|
||||
console.error(`❌ [${label}] Error:`, err);
|
||||
console.error(`❌ [${label}] Error:`, {
|
||||
db: getDbConnectionSummary(),
|
||||
code: err.code,
|
||||
errno: err.errno,
|
||||
syscall: err.syscall,
|
||||
address: err.address,
|
||||
port: err.port,
|
||||
message: err.message
|
||||
});
|
||||
res.status(500).json({ error: err.message });
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user