mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
[PackWorker] wait for the db setup before starting to process updates
This commit is contained in:
parent
31ad29e8c4
commit
41a65ee41e
1 changed files with 16 additions and 5 deletions
|
@ -18,7 +18,7 @@ let project_id, doc_id
|
|||
const Settings = require('settings-sharelatex')
|
||||
const async = require('async')
|
||||
const _ = require('underscore')
|
||||
const { db, ObjectId } = require('./mongodb')
|
||||
const { db, ObjectId, waitForDb } = require('./mongodb')
|
||||
const fs = require('fs')
|
||||
const Metrics = require('metrics-sharelatex')
|
||||
Metrics.initialize('track-changes')
|
||||
|
@ -160,10 +160,21 @@ const ObjectIdFromDate = function (date) {
|
|||
// find packs to be marked as finalised:true, those which have a newer pack present
|
||||
// then only consider finalised:true packs for archiving
|
||||
|
||||
if (pending != null) {
|
||||
waitForDb()
|
||||
.then(() => {
|
||||
if (pending != null) {
|
||||
logger.log(`got ${pending.length} entries from ${source}`)
|
||||
processUpdates(pending)
|
||||
} else {
|
||||
} else {
|
||||
processFromOneWeekAgo()
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
logger.fatal({ err }, 'cannot connect to mongo, exiting')
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
function processFromOneWeekAgo() {
|
||||
const oneWeekAgo = new Date(Date.now() - 7 * DAYS)
|
||||
db.docHistory
|
||||
.find(
|
||||
|
|
Loading…
Reference in a new issue