From ecfadd43b8eaaa68e5cedb49745855fdeb7463e2 Mon Sep 17 00:00:00 2001 From: Pedro Rosario Date: Thu, 9 May 2019 09:39:22 -0400 Subject: [PATCH 1/3] Add semaphore implementation --- lib/services/db.js | 1 + lib/setup.js | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/services/db.js b/lib/services/db.js index 3161f43d..e8d6d6c5 100644 --- a/lib/services/db.js +++ b/lib/services/db.js @@ -130,6 +130,7 @@ module.exports.registerStorage = registerStorage; module.exports.put; module.exports.get; module.exports.del; +module.exports.applyLock; module.exports.batch; module.exports.putMeta; module.exports.patchMeta; diff --git a/lib/setup.js b/lib/setup.js index 9dcc0e12..931d50c2 100644 --- a/lib/setup.js +++ b/lib/setup.js @@ -64,7 +64,10 @@ module.exports = function (options = {}) { .then(() => db.registerStorage(storage)) .then(() => amphoraPlugins.registerPlugins(plugins)) .then(() => { router = routes(app, providers, sessionStore); }) - .then(() => internalBootstrap(bootstrap)) + + // TODO: Must make this optional + .then(() => db.applyLock('bootstrap', () => internalBootstrap(bootstrap))) + .then(() => router); }; From 0029396e18f51a0552cce99a53ff707b6a7d88d2 Mon Sep 17 00:00:00 2001 From: Pedro Rosario Date: Wed, 29 May 2019 15:29:47 -0400 Subject: [PATCH 2/3] Make lock optional --- lib/setup.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/setup.js b/lib/setup.js index 931d50c2..86a0cbc1 100644 --- a/lib/setup.js +++ b/lib/setup.js @@ -64,10 +64,11 @@ module.exports = function (options = {}) { .then(() => db.registerStorage(storage)) .then(() => amphoraPlugins.registerPlugins(plugins)) .then(() => { router = routes(app, providers, sessionStore); }) - - // TODO: Must make this optional - .then(() => db.applyLock('bootstrap', () => internalBootstrap(bootstrap))) - + .then(() => console.log('\n\n ======>', db.applyLock)) + .then(() => + db.applyLock + ? db.applyLock('bootstrap', internalBootstrap) + : internalBootstrap(bootstrap)) .then(() => router); }; From 09346010b5ef8a7c636561c7862b86bb33acc88b Mon Sep 17 00:00:00 2001 From: Pedro Rosario Date: Wed, 29 May 2019 16:06:47 -0400 Subject: [PATCH 3/3] Remove console.log --- lib/setup.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/setup.js b/lib/setup.js index 86a0cbc1..947195a3 100644 --- a/lib/setup.js +++ b/lib/setup.js @@ -64,7 +64,6 @@ module.exports = function (options = {}) { .then(() => db.registerStorage(storage)) .then(() => amphoraPlugins.registerPlugins(plugins)) .then(() => { router = routes(app, providers, sessionStore); }) - .then(() => console.log('\n\n ======>', db.applyLock)) .then(() => db.applyLock ? db.applyLock('bootstrap', internalBootstrap)