fix(native): remove obsolete workers service; restart only backend; add API request logging and preflight handler; keep static assets outside CORS
Mirror to GitHub / mirror (push) Successful in 33s
Test and Lint / backend-test (push) Successful in 1m31s
Test and Lint / frontend-test (push) Successful in 2m8s
Version and Release / version-bump (push) Successful in 56s
Version and Release / trigger-drone (push) Successful in 3s

This commit is contained in:
2025-09-09 20:39:58 +02:00
parent 531831e84b
commit f3604b438b
2 changed files with 32 additions and 4 deletions
+18
View File
@@ -115,6 +115,8 @@ const corsOptions = {
// Only attach CORS to API endpoints, not static assets
app.use('/api', cors(corsOptions));
// Handle preflight explicitly for API paths
app.options('/api/*', cors(corsOptions));
// Initialize rate limiters (they will be created dynamically)
let generalRateLimiter;
@@ -138,6 +140,22 @@ async function initializeRateLimiters() {
app.use(express.json({ limit: '100mb' }));
app.use(express.urlencoded({ extended: true, limit: '100mb' }));
// Request logging for API routes (with timestamps)
const apiRequestLogger = (req, res, next) => {
try {
const started = Date.now();
const ts = new Date().toISOString();
logger.info(`[${ts}] ${req.method} ${req.originalUrl}`);
res.on('finish', () => {
const ms = Date.now() - started;
const tsDone = new Date().toISOString();
logger.info(`[${tsDone}] ${req.method} ${req.originalUrl} -> ${res.statusCode} (${ms}ms)`);
});
} catch (_) {}
next();
};
app.use('/api', apiRequestLogger);
// Maintenance mode middleware - add after body parsing but before routes
app.use(maintenanceMiddleware);
+14 -4
View File
@@ -690,8 +690,15 @@ EOF
# Start services
log_step "Starting services..."
systemctl daemon-reload
systemctl enable picpeak-backend picpeak-workers
systemctl start picpeak-backend picpeak-workers
systemctl enable picpeak-backend
# Stop/remove legacy workers service if present
if systemctl list-unit-files | grep -q '^picpeak-workers.service'; then
systemctl disable picpeak-workers || true
systemctl stop picpeak-workers || true
rm -f /etc/systemd/system/picpeak-workers.service
systemctl daemon-reload
fi
systemctl start picpeak-backend
log_success "Native installation completed!"
}
@@ -1001,7 +1008,10 @@ update_native_installation() {
log_step "Updating native installation..."
# Stop services
systemctl stop picpeak-backend picpeak-workers
systemctl stop picpeak-backend || true
if systemctl list-unit-files | grep -q '^picpeak-workers.service'; then
systemctl stop picpeak-workers || true
fi
# Backup current configuration
if [[ -f "$NATIVE_APP_DIR/app/backend/.env" ]]; then
@@ -1042,7 +1052,7 @@ update_native_installation() {
fi
# Restart services
systemctl restart picpeak-backend picpeak-workers
systemctl restart picpeak-backend
log_success "Native installation updated successfully!"
}