Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const mongoURL = Database.URI || process.env.DATABASE_URI as string;
- const mongoOPTIONS = {
- useNewUrlParser: true,
- autoReconnect: true,
- reconnectTries: Number.MAX_VALUE,
- bufferMaxEntries: 0
- };
- const connectWithRetry = function() {
- return mongoose.connect( mongoURL, mongoOPTIONS, (err) => {
- if ( err ) {
- console.error('Failed to connect to mongo on startup - retrying in 5 sec', err );
- setTimeout(connectWithRetry, 5000);
- }
- });
- };
- connectWithRetry();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement