mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-15 03:09:32 +02:00
Improve production environment diagnostics and error handling
Add diagnostic scripts and enhance server configuration to better identify and resolve production issues, including 502 errors and static file serving problems. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 54292eb6-296c-47a3-8f4e-c9967863556c Replit-Commit-Checkpoint-Type: full_checkpoint
This commit is contained in:
1 parent
8256d0b965
commit
464eb0bfad
3 files changed
+125
-2
No files matched your search
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
// Script de diagnostic pour la production LogiFlow
|
||||
// Usage: node debug-production.js [URL_BASE]
|
||||
|
||||
const url = process.argv[2] || 'https://logiflow.ffnancy.fr';
|
||||
|
||||
const runDiagnostics = async () => {
|
||||
console.log(`🔍 Diagnostic de production pour ${url}\n`);
|
||||
|
||||
const endpoints = [
|
||||
{ path: '/api/health', desc: 'Health Check' },
|
||||
{ path: '/api/user', desc: 'API User (attendu: 401)' },
|
||||
{ path: '/api/default-credentials-check', desc: 'Credentials Check' },
|
||||
{ path: '/', desc: 'Page principale' },
|
||||
{ path: '/sav', desc: 'Page SAV' }
|
||||
];
|
||||
|
||||
for (const endpoint of endpoints) {
|
||||
try {
|
||||
console.log(`📡 Test ${endpoint.desc}: ${url}${endpoint.path}`);
|
||||
|
||||
const response = await fetch(`${url}${endpoint.path}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'User-Agent': 'LogiFlow-Debug/1.0'
|
||||
}
|
||||
});
|
||||
|
||||
console.log(` Status: ${response.status} ${response.statusText}`);
|
||||
|
||||
if (endpoint.path === '/api/health' && response.ok) {
|
||||
const data = await response.json();
|
||||
console.log(` Détails:`, data);
|
||||
}
|
||||
|
||||
if (response.status === 502) {
|
||||
console.log(` ❌ Erreur 502: Service indisponible ou problème de proxy`);
|
||||
} else if (response.ok || response.status === 401) {
|
||||
console.log(` ✅ Service répond correctement`);
|
||||
} else {
|
||||
console.log(` ⚠️ Status inattendu`);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.log(` ❌ Erreur de connexion: ${error.message}`);
|
||||
}
|
||||
|
||||
console.log('');
|
||||
}
|
||||
|
||||
console.log('🔧 Actions recommandées:');
|
||||
console.log('1. Vérifier les logs Docker: docker-compose logs logiflow');
|
||||
console.log('2. Vérifier le status: docker-compose ps');
|
||||
console.log('3. Redémarrer si nécessaire: docker-compose restart logiflow');
|
||||
console.log('4. Forcer rebuild: docker-compose up --build -d');
|
||||
};
|
||||
|
||||
runDiagnostics().catch(console.error);
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script de vérification de santé pour LogiFlow en production
|
||||
echo "🔍 Vérification de santé LogiFlow Production"
|
||||
echo "=============================================="
|
||||
|
||||
# Vérifier le status des containers
|
||||
echo "📊 Status des containers:"
|
||||
docker-compose ps
|
||||
|
||||
echo ""
|
||||
echo "🏥 Health checks:"
|
||||
docker-compose exec logiflow wget --spider -q http://localhost:3000/api/health
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "✅ Health check API OK"
|
||||
else
|
||||
echo "❌ Health check API FAILED"
|
||||
fi
|
||||
|
||||
# Vérifier les fichiers statiques
|
||||
echo ""
|
||||
echo "📁 Vérification des fichiers statiques:"
|
||||
docker-compose exec logiflow ls -la /app/dist/public/ | head -10
|
||||
|
||||
# Test des endpoints critiques
|
||||
echo ""
|
||||
echo "🌐 Test des endpoints:"
|
||||
echo "Health:"
|
||||
curl -s -o /dev/null -w "Status: %{http_code}\n" https://logiflow.ffnancy.fr/api/health
|
||||
|
||||
echo "Root:"
|
||||
curl -s -o /dev/null -w "Status: %{http_code}\n" https://logiflow.ffnancy.fr/
|
||||
|
||||
echo "SAV:"
|
||||
curl -s -o /dev/null -w "Status: %{http_code}\n" https://logiflow.ffnancy.fr/sav
|
||||
|
||||
# Dernières logs
|
||||
echo ""
|
||||
echo "📋 Dernières logs (10 lignes):"
|
||||
docker-compose logs --tail=10 logiflow
|
||||
|
||||
echo ""
|
||||
echo "🔧 Si erreur 502 persistent:"
|
||||
echo " docker-compose restart logiflow"
|
||||
echo " docker-compose up --build -d # Rebuild complet"
|
||||
@@ -45,7 +45,9 @@ async function registerProductionRoutes(app: Express): Promise<Server> {
|
||||
status: 'healthy',
|
||||
timestamp: new Date().toISOString(),
|
||||
environment: 'production',
|
||||
database: 'connected'
|
||||
database: 'connected',
|
||||
port: process.env.PORT || 3000,
|
||||
publicPath: join(__dirname, 'public')
|
||||
});
|
||||
});
|
||||
|
||||
@@ -180,12 +182,29 @@ console.log('🐳 Serving static files from:', publicPath);
|
||||
app.use('/assets', express.static(join(publicPath, 'assets')));
|
||||
app.use('/', express.static(publicPath));
|
||||
|
||||
// Add explicit root route handler
|
||||
app.get('/', (req, res) => {
|
||||
console.log('🏠 ROOT: Serving index.html for root request');
|
||||
res.sendFile(join(publicPath, 'index.html'), (err) => {
|
||||
if (err) {
|
||||
console.error('❌ ROOT: Error serving index.html:', err);
|
||||
res.status(500).send('Error loading application');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// SPA fallback - serve index.html for all non-API routes
|
||||
app.get('*', (req, res, next) => {
|
||||
if (req.path.startsWith('/api/')) {
|
||||
return next();
|
||||
}
|
||||
res.sendFile(join(publicPath, 'index.html'));
|
||||
console.log(`📄 SPA: Serving index.html for ${req.path}`);
|
||||
res.sendFile(join(publicPath, 'index.html'), (err) => {
|
||||
if (err) {
|
||||
console.error(`❌ SPA: Error serving index.html for ${req.path}:`, err);
|
||||
res.status(500).send('Error loading application');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const port = process.env.PORT ? parseInt(process.env.PORT) : 3000;
|
||||
|
||||
Reference in new issue
Block a user