mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-28 15:51:39 +00:00
[PackWorker] fix the db cleanup process -- we do not expose db.close
This commit is contained in:
parent
41a65ee41e
commit
2c8916f2e0
2 changed files with 15 additions and 2 deletions
|
@ -15,10 +15,11 @@
|
||||||
*/
|
*/
|
||||||
let LIMIT, pending
|
let LIMIT, pending
|
||||||
let project_id, doc_id
|
let project_id, doc_id
|
||||||
|
const { callbackify } = require('util')
|
||||||
const Settings = require('settings-sharelatex')
|
const Settings = require('settings-sharelatex')
|
||||||
const async = require('async')
|
const async = require('async')
|
||||||
const _ = require('underscore')
|
const _ = require('underscore')
|
||||||
const { db, ObjectId, waitForDb } = require('./mongodb')
|
const { db, ObjectId, waitForDb, closeDb } = require('./mongodb')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const Metrics = require('metrics-sharelatex')
|
const Metrics = require('metrics-sharelatex')
|
||||||
Metrics.initialize('track-changes')
|
Metrics.initialize('track-changes')
|
||||||
|
@ -84,7 +85,7 @@ const finish = function () {
|
||||||
clearTimeout(shutDownTimer)
|
clearTimeout(shutDownTimer)
|
||||||
}
|
}
|
||||||
logger.log('closing db')
|
logger.log('closing db')
|
||||||
return db.close(function () {
|
callbackify(closeDb)(function () {
|
||||||
logger.log('closing LockManager Redis Connection')
|
logger.log('closing LockManager Redis Connection')
|
||||||
return LockManager.close(function () {
|
return LockManager.close(function () {
|
||||||
logger.log(
|
logger.log(
|
||||||
|
|
|
@ -23,8 +23,20 @@ async function setupDb() {
|
||||||
db.projectHistoryMetaData = internalDb.collection('projectHistoryMetaData')
|
db.projectHistoryMetaData = internalDb.collection('projectHistoryMetaData')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function closeDb() {
|
||||||
|
let client
|
||||||
|
try {
|
||||||
|
client = await clientPromise
|
||||||
|
} catch (e) {
|
||||||
|
// there is nothing to close
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return client.close()
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
db,
|
db,
|
||||||
ObjectId,
|
ObjectId,
|
||||||
|
closeDb,
|
||||||
waitForDb
|
waitForDb
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue