From 7889baccd634598853d3e67ea8b77b58601f6728 Mon Sep 17 00:00:00 2001 From: Torsten Schulz Date: Mon, 8 Jul 2024 07:38:31 +0200 Subject: [PATCH] timeout removed --- config/database.js | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/config/database.js b/config/database.js index 7d6637f..3636a78 100644 --- a/config/database.js +++ b/config/database.js @@ -2,7 +2,37 @@ const { Sequelize } = require('sequelize'); const sequelize = new Sequelize('miriamgemeinde', 'miriam_user', 'qTCTTWwpEwy3vPDU', { host: 'tsschulz.de', - dialect: 'mysql' + dialect: 'mysql', + retry: { + match: [ + /ConnectionError/, + /SequelizeConnectionError/, + /SequelizeConnectionRefusedError/, + /SequelizeHostNotFoundError/, + /SequelizeHostNotReachableError/, + /SequelizeInvalidConnectionError/, + /SequelizeConnectionTimedOutError/ + ], + max: 5 // Maximal 5 Versuche + }, + pool: { + max: 5, + min: 0, + acquire: 30000, + idle: 10000 + } }); +async function connectWithRetry() { + try { + await sequelize.authenticate(); + console.log('Connection has been established successfully.'); + } catch (error) { + console.error('Unable to connect to the database:', error); + setTimeout(connectWithRetry, 5000); + } +} + +connectWithRetry(); + module.exports = sequelize;