fix: Prevent nodemon restarts during policy creation
- Move temp directory outside app folder to /tmp/minio-webui-temp - Add nodemon.json to ignore temp, logs, and node_modules - Add TEMP_DIR environment variable configuration - Add cleanup routine for old temporary policy files (>1 hour) - Update both dev and production Dockerfiles - Update docker-compose configurations This fixes the 500 error during QuickStartWizard policy creation caused by nodemon restarting when temporary files were created. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
NODE_ENV=production
|
||||
PORT=7510
|
||||
LOG_LEVEL=info
|
||||
TEMP_DIR=/tmp/minio-webui-temp
|
||||
|
||||
# Authentication
|
||||
ADMIN_PASSWORD_HASH=$2b$12$REPLACE_WITH_ACTUAL_HASH
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"watch": ["src"],
|
||||
"ext": "js,json",
|
||||
"ignore": [
|
||||
"src/**/*.spec.js",
|
||||
"node_modules",
|
||||
"logs",
|
||||
"temp",
|
||||
"*.log",
|
||||
"*.tmp",
|
||||
"*.temp"
|
||||
],
|
||||
"delay": "1000"
|
||||
}
|
||||
@@ -19,11 +19,34 @@ class MinIOService {
|
||||
async ensureTempDir() {
|
||||
try {
|
||||
await fs.mkdir(this.tempDir, { recursive: true });
|
||||
// Clean up old temp files (older than 1 hour)
|
||||
this.cleanupTempFiles();
|
||||
} catch (error) {
|
||||
logger.error('Failed to create temp directory:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async cleanupTempFiles() {
|
||||
try {
|
||||
const files = await fs.readdir(this.tempDir);
|
||||
const now = Date.now();
|
||||
const oneHour = 60 * 60 * 1000;
|
||||
|
||||
for (const file of files) {
|
||||
if (file.endsWith('.json')) {
|
||||
const filePath = path.join(this.tempDir, file);
|
||||
const stats = await fs.stat(filePath);
|
||||
if (now - stats.mtimeMs > oneHour) {
|
||||
await fs.unlink(filePath);
|
||||
logger.debug(`Cleaned up old temp file: ${file}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
logger.debug('Error cleaning temp files:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Execute MinIO CLI command with timeout and error handling
|
||||
async executeCommand(command, options = {}) {
|
||||
const { timeout = 30000, parseJson = false } = options;
|
||||
|
||||
@@ -13,7 +13,7 @@ services:
|
||||
NODE_ENV: development
|
||||
PORT: 7510
|
||||
LOG_DIR: /app/logs
|
||||
TEMP_DIR: /app/temp
|
||||
TEMP_DIR: /tmp/minio-webui-temp
|
||||
LOG_LEVEL: debug
|
||||
env_file:
|
||||
- .env
|
||||
@@ -24,7 +24,7 @@ services:
|
||||
- ./backend/package.json:/app/package.json
|
||||
- ./backend/package-lock.json:/app/package-lock.json
|
||||
- backend-logs:/app/logs
|
||||
- backend-temp:/app/temp
|
||||
- backend-temp:/tmp/minio-webui-temp
|
||||
- mc-config:/home/node/.mc
|
||||
depends_on:
|
||||
- redis
|
||||
|
||||
@@ -30,9 +30,10 @@ RUN addgroup -g 1001 -S nodejs && \
|
||||
adduser -S nodejs -u 1001
|
||||
|
||||
# Create necessary directories with proper permissions
|
||||
RUN mkdir -p logs temp && \
|
||||
RUN mkdir -p logs /tmp/minio-webui-temp && \
|
||||
chown -R nodejs:nodejs /app && \
|
||||
chmod 755 logs temp
|
||||
chown nodejs:nodejs /tmp/minio-webui-temp && \
|
||||
chmod 755 logs /tmp/minio-webui-temp
|
||||
|
||||
# Switch to non-root user
|
||||
USER nodejs
|
||||
|
||||
@@ -24,8 +24,8 @@ RUN NODE_ENV=development npm install && \
|
||||
npm rebuild bcrypt --build-from-source
|
||||
|
||||
# Create necessary directories
|
||||
RUN mkdir -p logs temp && \
|
||||
chmod 755 logs temp
|
||||
RUN mkdir -p logs /tmp/minio-webui-temp && \
|
||||
chmod 755 logs /tmp/minio-webui-temp
|
||||
|
||||
# Copy application files
|
||||
COPY . .
|
||||
|
||||
Reference in New Issue
Block a user