feat: warningMessage quota IA dans rapports d'import + redémarrage auto services
This commit is contained in:
@@ -10,6 +10,10 @@ import { registerOAuthRoutes } from "./oauth";
|
||||
import { appRouter } from "../routers";
|
||||
import { createContext } from "./context";
|
||||
import { serveStatic, setupVite } from "./vite";
|
||||
import { getAllUsers } from "../db";
|
||||
import { startEmailImportService } from "../emailImportService";
|
||||
import { startFolderImportService } from "../folderImportService";
|
||||
import { getImportSettingsByUser } from "../db";
|
||||
|
||||
function isPortAvailable(port: number): Promise<boolean> {
|
||||
return new Promise(resolve => {
|
||||
@@ -164,6 +168,31 @@ async function startServer() {
|
||||
server.listen(port, () => {
|
||||
console.log(`Server running on http://localhost:${port}/`);
|
||||
});
|
||||
|
||||
// Redémarrer automatiquement les services actifs (IMAP, dossier) après redémarrage du serveur
|
||||
setTimeout(async () => {
|
||||
try {
|
||||
const users = await getAllUsers();
|
||||
for (const user of users) {
|
||||
const settings = await getImportSettingsByUser(user.id);
|
||||
if (!settings) continue;
|
||||
if (settings.emailImportEnabled === 1) {
|
||||
console.log(`[AutoRestart] Restarting email import service for user ${user.id}...`);
|
||||
await startEmailImportService(user.id).catch(e =>
|
||||
console.error(`[AutoRestart] Failed to restart email service for user ${user.id}:`, e.message)
|
||||
);
|
||||
}
|
||||
if ((settings as any).autoImportEnabled === 1) {
|
||||
console.log(`[AutoRestart] Restarting folder import service for user ${user.id}...`);
|
||||
await startFolderImportService(user.id).catch(e =>
|
||||
console.error(`[AutoRestart] Failed to restart folder service for user ${user.id}:`, e.message)
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (e: any) {
|
||||
console.error('[AutoRestart] Error during service auto-restart:', e.message);
|
||||
}
|
||||
}, 5000); // Attendre 5s que le serveur soit prêt
|
||||
}
|
||||
|
||||
startServer().catch(console.error);
|
||||
|
||||
Reference in New Issue
Block a user