Database connectivity in your App

If on deployment, you deployed a NodeChef hosted database with your application, the NodeChef runtime will set the following environment variables automatically on your behalf.

The default environment variable DATABASE_URL is set for all databases except the Redis database. The format of the connection is described below:

[database type]://[username]:[password]@[host]:[port]/[database name] [Database type]: mongodb postgres mysql [Examples]: postgres:// mysql:// mongodb://

In addition to the DATABASE_URL environment variable, the following environment variables DB_HOST, DB_USER, DB_PASSWORD and DB_NAME are also set.

For the MongoDB database, if you setup a replica set for your deployment, the connection string provided will contain multiple host addresses which will be used by the MongoDB driver to automatically failover to the secondary.

For PostgreSQL and MySQL, the connection string provided will always point to the master node. When the NodeChef platform detects a failure it will automaticaly failover to the standby node and update the DNS records to point to the new master node. Your application containers are also restarted as well.