Skip to content

Instantly share code, notes, and snippets.

@bogoslavskiy
Created March 5, 2020 14:38
Show Gist options
  • Save bogoslavskiy/9cf630cb02adb9485efc286cedd6cd13 to your computer and use it in GitHub Desktop.
Save bogoslavskiy/9cf630cb02adb9485efc286cedd6cd13 to your computer and use it in GitHub Desktop.
[...]
httpServer.listen({ port: config.port }, () => {
console.log(`πŸš€ Server ready at http://localhost:${config.port}${server.graphqlPath}`)
console.log(`πŸš€ Subscriptions ready at ws://localhost:${config.port}${server.subscriptionsPath}`)
const connectMongoWithRetry = () => {
mongoose
.connect(config.mongoURI, {
useNewUrlParser: true,
useCreateIndex: true,
useUnifiedTopology: true,
})
.then(() => console.log(`πŸš€ MongoDB connection ready at ${config.mongoURI}`))
.catch(err => {
console.error('MongoDB connection error', err);
setTimeout(connectMongoWithRetry, 5000);
});
};
connectMongoWithRetry();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment