Advertisement
Guest User

Untitled

a guest
May 21st, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. const mongoURL = Database.URI || process.env.DATABASE_URI as string;
  2.  
  3.  
  4. const mongoOPTIONS = {
  5. useNewUrlParser: true,
  6. autoReconnect: true,
  7. reconnectTries: Number.MAX_VALUE,
  8. bufferMaxEntries: 0
  9. };
  10.  
  11.  
  12. const connectWithRetry = function() {
  13.  
  14. return mongoose.connect( mongoURL, mongoOPTIONS, (err) => {
  15. if ( err ) {
  16. console.error('Failed to connect to mongo on startup - retrying in 5 sec', err );
  17. setTimeout(connectWithRetry, 5000);
  18. }
  19. });
  20.  
  21. };
  22.  
  23. connectWithRetry();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement