added ability to turn off checks/updates via config

This commit is contained in:
bill bittner 2018-06-28 11:31:21 -07:00
parent 8b24b2f0cb
commit e224926f8b

View file

@ -35,6 +35,10 @@ const speechPassport = require('./server/speechPassport');
const { const {
details: { port: PORT }, details: { port: PORT },
auth: { sessionKey }, auth: { sessionKey },
startup: {
performChecks,
performUpdates,
},
} = require('@config/siteConfig'); } = require('@config/siteConfig');
function Server () { function Server () {
@ -113,17 +117,30 @@ function Server () {
db.sequelize.sync(); db.sequelize.sync();
}) })
}; };
this.performChecksAndUpdates = () => { this.performChecks = () => {
logger.info(`Getting wallet balance and updating resources`); if (!performChecks) {
return;
}
logger.info(`Performing checks...`);
return Promise.all([ return Promise.all([
getWalletBalance(), getWalletBalance(),
])
.then(([walletBalance]) => {
logger.info('Starting LBC balance:', walletBalance);
})
};
this.performUpdates = () => {
if (!performUpdates) {
return;
}
logger.info(`Peforming updates...`);
return Promise.all([
[], [],
db.Tor.refreshTable(), db.Tor.refreshTable(),
]) ])
.then(([walletBalance, updatedBlockedList, updatedTorList]) => { .then(([updatedBlockedList, updatedTorList]) => {
logger.info('Starting LBC balance:', walletBalance); logger.info('Blocked list updated, length:', updatedBlockedList.length);
logger.info('Blocked list length:', updatedBlockedList.length); logger.info('Tor list updated, length:', updatedTorList.length);
logger.info('Tor list length:', updatedTorList.length);
}) })
}; };
this.start = () => { this.start = () => {
@ -135,10 +152,13 @@ function Server () {
return this.startServerListening(); return this.startServerListening();
}) })
.then(() => { .then(() => {
return this.performChecksAndUpdates(); return Promise.all([
this.performChecks(),
this.performUpdates(),
])
}) })
.then(() => { .then(() => {
logger.info('Spee.ch startup is complete.'); logger.info('Spee.ch startup is complete');
}) })
.catch(error => { .catch(error => {
if (error.code === 'ECONNREFUSED') { if (error.code === 'ECONNREFUSED') {