From e224926f8bc9da1ec5fae3178715b5dd85444697 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Thu, 28 Jun 2018 11:31:21 -0700 Subject: [PATCH] added ability to turn off checks/updates via config --- index.js | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index ab2af386..d4eb8274 100644 --- a/index.js +++ b/index.js @@ -35,6 +35,10 @@ const speechPassport = require('./server/speechPassport'); const { details: { port: PORT }, auth: { sessionKey }, + startup: { + performChecks, + performUpdates, + }, } = require('@config/siteConfig'); function Server () { @@ -113,17 +117,30 @@ function Server () { db.sequelize.sync(); }) }; - this.performChecksAndUpdates = () => { - logger.info(`Getting wallet balance and updating resources`); + this.performChecks = () => { + if (!performChecks) { + return; + } + logger.info(`Performing checks...`); return Promise.all([ getWalletBalance(), + ]) + .then(([walletBalance]) => { + logger.info('Starting LBC balance:', walletBalance); + }) + }; + this.performUpdates = () => { + if (!performUpdates) { + return; + } + logger.info(`Peforming updates...`); + return Promise.all([ [], db.Tor.refreshTable(), ]) - .then(([walletBalance, updatedBlockedList, updatedTorList]) => { - logger.info('Starting LBC balance:', walletBalance); - logger.info('Blocked list length:', updatedBlockedList.length); - logger.info('Tor list length:', updatedTorList.length); + .then(([updatedBlockedList, updatedTorList]) => { + logger.info('Blocked list updated, length:', updatedBlockedList.length); + logger.info('Tor list updated, length:', updatedTorList.length); }) }; this.start = () => { @@ -135,10 +152,13 @@ function Server () { return this.startServerListening(); }) .then(() => { - return this.performChecksAndUpdates(); + return Promise.all([ + this.performChecks(), + this.performUpdates(), + ]) }) .then(() => { - logger.info('Spee.ch startup is complete.'); + logger.info('Spee.ch startup is complete'); }) .catch(error => { if (error.code === 'ECONNREFUSED') {