fix: logger.js hardcoded server.log path breaks non-root container user
server/utils/logger.js was still writing to ../../server.log relative to __dirname (/app/server.log) which is root-owned. The non-root node user (UID 1000) cannot write there, causing an EACCES crash on startup. Fix: use DATA_DIR env var (same as index.js) so all log writes go to /app/data/server.log which is owned by the node user.
This commit is contained in:
@@ -1,7 +1,12 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const logFile = fs.createWriteStream(path.join(__dirname, '../../server.log'), { flags: 'a' });
|
// Use DATA_DIR so the non-root container user (UID 1000) can write logs.
|
||||||
|
// Falls back to ../../data/server.log (same directory index.js uses).
|
||||||
|
const DATA_DIR = process.env.DATA_DIR || path.join(__dirname, '../../data');
|
||||||
|
if (!fs.existsSync(DATA_DIR)) fs.mkdirSync(DATA_DIR, { recursive: true });
|
||||||
|
|
||||||
|
const logFile = fs.createWriteStream(path.join(DATA_DIR, 'server.log'), { flags: 'a' });
|
||||||
|
|
||||||
function logToFile(message) {
|
function logToFile(message) {
|
||||||
logFile.write(`[${new Date().toISOString()}] ${message}\n`);
|
logFile.write(`[${new Date().toISOString()}] ${message}\n`);
|
||||||
|
|||||||
Reference in New Issue
Block a user