From 94bd7811a158a6f85456f0fcc669dffe56989a65 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Mon, 21 Jan 2019 17:26:27 -0800 Subject: [PATCH] Allowing server to start without iRedMail postgres connection --- bin/server.js | 14 +++++++++----- config/env/min-config.js | 3 +++ config/index.js | 4 +++- 3 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 config/env/min-config.js diff --git a/bin/server.js b/bin/server.js index ddaa3f9..1b47ef2 100644 --- a/bin/server.js +++ b/bin/server.js @@ -54,12 +54,16 @@ async function startServer () { await app.listen(config.port) console.log(`Server started on ${config.port}`) - const iRedMail = new IRedMail() - await iRedMail.sequelize.authenticate() - console.log('Connection to the iRedMail postgres database has been established successfully.') + try { + const iRedMail = new IRedMail() + await iRedMail.sequelize.authenticate() + console.log('Connection to the iRedMail postgres database has been established successfully.') - // Attach to iRedMail instantiation to the context object. - app.context.iRedMail = iRedMail + // Attach to iRedMail instantiation to the context object. + app.context.iRedMail = iRedMail + } catch (err) { + console.log(`Could not connect to iRedMail instance.`) + } return app } diff --git a/config/env/min-config.js b/config/env/min-config.js new file mode 100644 index 0000000..1e08603 --- /dev/null +++ b/config/env/min-config.js @@ -0,0 +1,3 @@ +module.exports = { + port: process.env.PORT || 5000 +} diff --git a/config/index.js b/config/index.js index 395a90d..d8e1d3a 100644 --- a/config/index.js +++ b/config/index.js @@ -2,7 +2,9 @@ let common try { common = require('./env/common') -} catch (err) {} +} catch (err) { + common = require('./env/min-config') +} // Default to development environment. const env = process.env.NODE_ENV || 'development'