Skip to content

Commit

Permalink
Fix double initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
mjlescano committed Jul 9, 2017
1 parent 3f79a40 commit 268b98a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ const notifier = module.exports = {}
* @return {Notifier}
*/

let initialization = null

notifier.init = function init () {
return Promise.all([
if (initialization) return initialization

initialization = Promise.all([
require('./lib/db'),
require('./lib/mailer'),
require('./lib/agenda')
Expand All @@ -36,6 +40,8 @@ notifier.init = function init () {
}).then((notifier) => {
return require('./lib/jobs').init(notifier)
}).catch((err) => { throw err })

return initialization
}

/**
Expand Down

0 comments on commit 268b98a

Please sign in to comment.