I think the problem you're facing is that the app tries to connect to the mongodb before it's up and running and it causes the app to shut down.
What you need to do is to retry connecting to the database when it's not responding and withhold your app's execution until the connection is established successfully.