-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* create crawler * Add crawler to cron scheduler * change indentation for a sane line length * cleanup - add comment * cleanup wordpress cache job * more clean * add opts to cache service - logging for testing * undo opts to cache service * remove logging * change ttl on clanService
- Loading branch information
Showing
5 changed files
with
43 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const Scheduler = require('../services/Scheduler') | ||
|
||
const successHandler = (name) => { | ||
console.debug('[debug] Cache updated', { name }) | ||
} | ||
const errorHandler = (e, name) => { | ||
console.error(e.toString(), { name, entrypoint: 'clanCacheCrawler.js' }) | ||
console.error(e.stack) | ||
} | ||
|
||
const warmupClans = async (clanService) => { | ||
try { | ||
await clanService.getAll(true) | ||
.then(() => successHandler('clanService::getAll(global)')) | ||
.catch((e) => errorHandler(e, 'clanService::getAll(global)')) | ||
} catch (e) { | ||
console.error('Error: clanCacheCrawler::warmupClans failed with "' + e.toString() + '"', | ||
{ entrypoint: 'clanCacheCrawler.js' }) | ||
console.error(e.stack) | ||
} | ||
} | ||
|
||
/** | ||
* @param {clanService} clanService | ||
* @return {Scheduler[]} | ||
*/ | ||
module.exports = (clanService) => { | ||
warmupClans(clanService).then(() => {}) | ||
|
||
const clansScheduler = new Scheduler('createClanCache', // Refresh cache every 59 minutes | ||
() => warmupClans(clanService).then(() => {}), 60 * 59 * 1000) | ||
clansScheduler.start() | ||
|
||
return clansScheduler | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters