mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #7906 from overleaf/em-downgrade-logs
Downgrade all INFO logs to DEBUG GitOrigin-RevId: 05ed582ef0721fcada059f0ad158565f50feca27
This commit is contained in:
parent
efcb06f0df
commit
e0d91eaa26
116 changed files with 487 additions and 423 deletions
|
@ -87,13 +87,13 @@ module.exports = MemoryMonitor = {
|
||||||
Metrics.gauge('memory.gc-interval', gcInterval)
|
Metrics.gauge('memory.gc-interval', gcInterval)
|
||||||
// Metrics.gauge("memory.cpu-time-bucket", CpuTimeBucket)
|
// Metrics.gauge("memory.cpu-time-bucket", CpuTimeBucket)
|
||||||
|
|
||||||
logger.log(mem, 'process.memoryUsage()')
|
logger.debug(mem, 'process.memoryUsage()')
|
||||||
|
|
||||||
if (global.gc != null && readyToGc()) {
|
if (global.gc != null && readyToGc()) {
|
||||||
const gcTime = executeAndTime(global.gc).toFixed(2)
|
const gcTime = executeAndTime(global.gc).toFixed(2)
|
||||||
const memAfterGc = inMegaBytes(process.memoryUsage())
|
const memAfterGc = inMegaBytes(process.memoryUsage())
|
||||||
const deltaMem = updateMemoryStats(memBeforeGc, memAfterGc)
|
const deltaMem = updateMemoryStats(memBeforeGc, memAfterGc)
|
||||||
logger.log(
|
logger.debug(
|
||||||
{
|
{
|
||||||
gcTime,
|
gcTime,
|
||||||
memBeforeGc,
|
memBeforeGc,
|
||||||
|
|
|
@ -53,7 +53,7 @@ module.exports = {
|
||||||
const start = new Date()
|
const start = new Date()
|
||||||
return _method.call(this, dbCommand, options, function () {
|
return _method.call(this, dbCommand, options, function () {
|
||||||
timer.done()
|
timer.done()
|
||||||
logger.log(
|
logger.debug(
|
||||||
{
|
{
|
||||||
query: dbCommand.query,
|
query: dbCommand.query,
|
||||||
query_type: type,
|
query_type: type,
|
||||||
|
@ -89,7 +89,7 @@ module.exports = {
|
||||||
const start = new Date()
|
const start = new Date()
|
||||||
return _method.call(this, ns, ops, options, function () {
|
return _method.call(this, ns, ops, options, function () {
|
||||||
timer.done()
|
timer.done()
|
||||||
logger.log(
|
logger.debug(
|
||||||
{
|
{
|
||||||
query: ops[0].q,
|
query: ops[0].q,
|
||||||
query_type: type,
|
query_type: type,
|
||||||
|
|
|
@ -130,10 +130,10 @@ describe('timeAsyncMethod', function () {
|
||||||
|
|
||||||
describe('when a logger is supplied', function () {
|
describe('when a logger is supplied', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
return (this.logger = { log: sinon.stub() })
|
return (this.logger = { debug: sinon.stub(), log: sinon.stub() })
|
||||||
})
|
})
|
||||||
|
|
||||||
return it('should also call logger.log', function (done) {
|
return it('should also call logger.debug', function (done) {
|
||||||
this.timeAsyncMethod(
|
this.timeAsyncMethod(
|
||||||
this.testObject,
|
this.testObject,
|
||||||
'nextNumber',
|
'nextNumber',
|
||||||
|
@ -145,7 +145,7 @@ describe('timeAsyncMethod', function () {
|
||||||
expect(result).to.equal(3)
|
expect(result).to.equal(3)
|
||||||
expect(this.TimerConstructor.callCount).to.equal(1)
|
expect(this.TimerConstructor.callCount).to.equal(1)
|
||||||
expect(this.Timer.done.callCount).to.equal(1)
|
expect(this.Timer.done.callCount).to.equal(1)
|
||||||
expect(this.logger.log.callCount).to.equal(1)
|
expect(this.logger.debug.callCount).to.equal(1)
|
||||||
return done()
|
return done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -36,7 +36,7 @@ module.exports = function (obj, methodName, prefix, logger) {
|
||||||
|
|
||||||
if (callback == null || typeof callback !== 'function') {
|
if (callback == null || typeof callback !== 'function') {
|
||||||
if (logger != null) {
|
if (logger != null) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
`[Metrics] expected wrapped method '${methodName}' to be invoked with a callback`
|
`[Metrics] expected wrapped method '${methodName}' to be invoked with a callback`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ module.exports = function (obj, methodName, prefix, logger) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ key, args: loggableArgs, elapsedTime },
|
{ key, args: loggableArgs, elapsedTime },
|
||||||
'[Metrics] timed async method call'
|
'[Metrics] timed async method call'
|
||||||
)
|
)
|
||||||
|
|
|
@ -16,7 +16,7 @@ if (!module.parent) {
|
||||||
logger.fatal({ err }, `Cannot bind to ${host}:${port}. Exiting.`)
|
logger.fatal({ err }, `Cannot bind to ${host}:${port}. Exiting.`)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
logger.info(`Chat starting up, listening on ${host}:${port}`)
|
logger.debug(`Chat starting up, listening on ${host}:${port}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
|
|
@ -22,7 +22,7 @@ async function sendThreadMessage(req, res) {
|
||||||
|
|
||||||
async function getAllThreads(req, res) {
|
async function getAllThreads(req, res) {
|
||||||
const { projectId } = req.params
|
const { projectId } = req.params
|
||||||
logger.log({ projectId }, 'getting all threads')
|
logger.debug({ projectId }, 'getting all threads')
|
||||||
const rooms = await ThreadManager.findAllThreadRooms(projectId)
|
const rooms = await ThreadManager.findAllThreadRooms(projectId)
|
||||||
const roomIds = rooms.map(r => r._id)
|
const roomIds = rooms.map(r => r._id)
|
||||||
const messages = await MessageManager.findAllMessagesInRooms(roomIds)
|
const messages = await MessageManager.findAllMessagesInRooms(roomIds)
|
||||||
|
@ -33,21 +33,21 @@ async function getAllThreads(req, res) {
|
||||||
async function resolveThread(req, res) {
|
async function resolveThread(req, res) {
|
||||||
const { projectId, threadId } = req.params
|
const { projectId, threadId } = req.params
|
||||||
const { user_id: userId } = req.body
|
const { user_id: userId } = req.body
|
||||||
logger.log({ userId, projectId, threadId }, 'marking thread as resolved')
|
logger.debug({ userId, projectId, threadId }, 'marking thread as resolved')
|
||||||
await ThreadManager.resolveThread(projectId, threadId, userId)
|
await ThreadManager.resolveThread(projectId, threadId, userId)
|
||||||
res.sendStatus(204)
|
res.sendStatus(204)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function reopenThread(req, res) {
|
async function reopenThread(req, res) {
|
||||||
const { projectId, threadId } = req.params
|
const { projectId, threadId } = req.params
|
||||||
logger.log({ projectId, threadId }, 'reopening thread')
|
logger.debug({ projectId, threadId }, 'reopening thread')
|
||||||
await ThreadManager.reopenThread(projectId, threadId)
|
await ThreadManager.reopenThread(projectId, threadId)
|
||||||
res.sendStatus(204)
|
res.sendStatus(204)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteThread(req, res) {
|
async function deleteThread(req, res) {
|
||||||
const { projectId, threadId } = req.params
|
const { projectId, threadId } = req.params
|
||||||
logger.log({ projectId, threadId }, 'deleting thread')
|
logger.debug({ projectId, threadId }, 'deleting thread')
|
||||||
const roomId = await ThreadManager.deleteThread(projectId, threadId)
|
const roomId = await ThreadManager.deleteThread(projectId, threadId)
|
||||||
await MessageManager.deleteAllMessagesInRoom(roomId)
|
await MessageManager.deleteAllMessagesInRoom(roomId)
|
||||||
res.sendStatus(204)
|
res.sendStatus(204)
|
||||||
|
@ -56,7 +56,7 @@ async function deleteThread(req, res) {
|
||||||
async function editMessage(req, res) {
|
async function editMessage(req, res) {
|
||||||
const { content, userId } = req.body
|
const { content, userId } = req.body
|
||||||
const { projectId, threadId, messageId } = req.params
|
const { projectId, threadId, messageId } = req.params
|
||||||
logger.log({ projectId, threadId, messageId, content }, 'editing message')
|
logger.debug({ projectId, threadId, messageId, content }, 'editing message')
|
||||||
const room = await ThreadManager.findOrCreateThread(projectId, threadId)
|
const room = await ThreadManager.findOrCreateThread(projectId, threadId)
|
||||||
const found = await MessageManager.updateMessage(
|
const found = await MessageManager.updateMessage(
|
||||||
room._id,
|
room._id,
|
||||||
|
@ -73,7 +73,7 @@ async function editMessage(req, res) {
|
||||||
|
|
||||||
async function deleteMessage(req, res) {
|
async function deleteMessage(req, res) {
|
||||||
const { projectId, threadId, messageId } = req.params
|
const { projectId, threadId, messageId } = req.params
|
||||||
logger.log({ projectId, threadId, messageId }, 'deleting message')
|
logger.debug({ projectId, threadId, messageId }, 'deleting message')
|
||||||
const room = await ThreadManager.findOrCreateThread(projectId, threadId)
|
const room = await ThreadManager.findOrCreateThread(projectId, threadId)
|
||||||
await MessageManager.deleteMessage(room._id, messageId)
|
await MessageManager.deleteMessage(room._id, messageId)
|
||||||
res.sendStatus(204)
|
res.sendStatus(204)
|
||||||
|
@ -81,12 +81,12 @@ async function deleteMessage(req, res) {
|
||||||
|
|
||||||
async function destroyProject(req, res) {
|
async function destroyProject(req, res) {
|
||||||
const { projectId } = req.params
|
const { projectId } = req.params
|
||||||
logger.log({ projectId }, 'destroying project')
|
logger.debug({ projectId }, 'destroying project')
|
||||||
const rooms = await ThreadManager.findAllThreadRoomsAndGlobalThread(projectId)
|
const rooms = await ThreadManager.findAllThreadRoomsAndGlobalThread(projectId)
|
||||||
const roomIds = rooms.map(r => r._id)
|
const roomIds = rooms.map(r => r._id)
|
||||||
logger.log({ projectId, roomIds }, 'deleting all messages in rooms')
|
logger.debug({ projectId, roomIds }, 'deleting all messages in rooms')
|
||||||
await MessageManager.deleteAllMessagesInRooms(roomIds)
|
await MessageManager.deleteAllMessagesInRooms(roomIds)
|
||||||
logger.log({ projectId }, 'deleting all threads in project')
|
logger.debug({ projectId }, 'deleting all threads in project')
|
||||||
await ThreadManager.deleteAllThreadsInProject(projectId)
|
await ThreadManager.deleteAllThreadsInProject(projectId)
|
||||||
res.sendStatus(204)
|
res.sendStatus(204)
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ async function _sendMessage(clientThreadId, req, res) {
|
||||||
.status(400)
|
.status(400)
|
||||||
.send(`Content too long (> ${MAX_MESSAGE_LENGTH} bytes)`)
|
.send(`Content too long (> ${MAX_MESSAGE_LENGTH} bytes)`)
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ clientThreadId, projectId, userId, content },
|
{ clientThreadId, projectId, userId, content },
|
||||||
'new message received'
|
'new message received'
|
||||||
)
|
)
|
||||||
|
@ -137,7 +137,7 @@ async function _getMessages(clientThreadId, req, res) {
|
||||||
} else {
|
} else {
|
||||||
limit = DEFAULT_MESSAGE_LIMIT
|
limit = DEFAULT_MESSAGE_LIMIT
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ limit, before, projectId, clientThreadId },
|
{ limit, before, projectId, clientThreadId },
|
||||||
'get message request received'
|
'get message request received'
|
||||||
)
|
)
|
||||||
|
@ -146,13 +146,13 @@ async function _getMessages(clientThreadId, req, res) {
|
||||||
clientThreadId
|
clientThreadId
|
||||||
)
|
)
|
||||||
const threadObjectId = thread._id
|
const threadObjectId = thread._id
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ limit, before, projectId, clientThreadId, threadObjectId },
|
{ limit, before, projectId, clientThreadId, threadObjectId },
|
||||||
'found or created thread'
|
'found or created thread'
|
||||||
)
|
)
|
||||||
let messages = await MessageManager.getMessages(threadObjectId, limit, before)
|
let messages = await MessageManager.getMessages(threadObjectId, limit, before)
|
||||||
messages = MessageFormatter.formatMessagesForClientSide(messages)
|
messages = MessageFormatter.formatMessagesForClientSide(messages)
|
||||||
logger.log({ projectId, messages }, 'got messages')
|
logger.debug({ projectId, messages }, 'got messages')
|
||||||
res.status(200).send(messages)
|
res.status(200).send(messages)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -258,13 +258,13 @@ Settings.processTooOld = false
|
||||||
if (Settings.processLifespanLimitMs) {
|
if (Settings.processLifespanLimitMs) {
|
||||||
Settings.processLifespanLimitMs +=
|
Settings.processLifespanLimitMs +=
|
||||||
Settings.processLifespanLimitMs * (Math.random() / 10)
|
Settings.processLifespanLimitMs * (Math.random() / 10)
|
||||||
logger.info(
|
logger.debug(
|
||||||
'Lifespan limited to ',
|
'Lifespan limited to ',
|
||||||
Date.now() + Settings.processLifespanLimitMs
|
Date.now() + Settings.processLifespanLimitMs
|
||||||
)
|
)
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
logger.log('shutting down, process is too old')
|
logger.debug('shutting down, process is too old')
|
||||||
Settings.processTooOld = true
|
Settings.processTooOld = true
|
||||||
}, Settings.processLifespanLimitMs)
|
}, Settings.processLifespanLimitMs)
|
||||||
}
|
}
|
||||||
|
@ -276,10 +276,10 @@ function runSmokeTest() {
|
||||||
smokeTest.lastRunSuccessful() &&
|
smokeTest.lastRunSuccessful() &&
|
||||||
Date.now() - CompileController.lastSuccessfulCompile < INTERVAL / 2
|
Date.now() - CompileController.lastSuccessfulCompile < INTERVAL / 2
|
||||||
) {
|
) {
|
||||||
logger.log('skipping smoke tests, got recent successful user compile')
|
logger.debug('skipping smoke tests, got recent successful user compile')
|
||||||
return setTimeout(runSmokeTest, INTERVAL / 2)
|
return setTimeout(runSmokeTest, INTERVAL / 2)
|
||||||
}
|
}
|
||||||
logger.log('running smoke tests')
|
logger.debug('running smoke tests')
|
||||||
smokeTest.triggerRun(err => {
|
smokeTest.triggerRun(err => {
|
||||||
if (err) logger.error({ err }, 'smoke tests failed')
|
if (err) logger.error({ err }, 'smoke tests failed')
|
||||||
setTimeout(runSmokeTest, INTERVAL)
|
setTimeout(runSmokeTest, INTERVAL)
|
||||||
|
@ -300,7 +300,7 @@ app.get('/smoke_test_force', (req, res) => smokeTest.sendNewResult(res))
|
||||||
|
|
||||||
app.use(function (error, req, res, next) {
|
app.use(function (error, req, res, next) {
|
||||||
if (error instanceof Errors.NotFoundError) {
|
if (error instanceof Errors.NotFoundError) {
|
||||||
logger.log({ err: error, url: req.url }, 'not found error')
|
logger.debug({ err: error, url: req.url }, 'not found error')
|
||||||
return res.sendStatus(404)
|
return res.sendStatus(404)
|
||||||
} else if (error.code === 'EPIPE') {
|
} else if (error.code === 'EPIPE') {
|
||||||
// inspect container returns EPIPE when shutting down
|
// inspect container returns EPIPE when shutting down
|
||||||
|
@ -362,19 +362,19 @@ const loadHttpServer = express()
|
||||||
|
|
||||||
loadHttpServer.post('/state/up', function (req, res, next) {
|
loadHttpServer.post('/state/up', function (req, res, next) {
|
||||||
STATE = 'up'
|
STATE = 'up'
|
||||||
logger.info('getting message to set server to down')
|
logger.debug('getting message to set server to down')
|
||||||
return res.sendStatus(204)
|
return res.sendStatus(204)
|
||||||
})
|
})
|
||||||
|
|
||||||
loadHttpServer.post('/state/down', function (req, res, next) {
|
loadHttpServer.post('/state/down', function (req, res, next) {
|
||||||
STATE = 'down'
|
STATE = 'down'
|
||||||
logger.info('getting message to set server to down')
|
logger.debug('getting message to set server to down')
|
||||||
return res.sendStatus(204)
|
return res.sendStatus(204)
|
||||||
})
|
})
|
||||||
|
|
||||||
loadHttpServer.post('/state/maint', function (req, res, next) {
|
loadHttpServer.post('/state/maint', function (req, res, next) {
|
||||||
STATE = 'maint'
|
STATE = 'maint'
|
||||||
logger.info('getting message to set server to maint')
|
logger.debug('getting message to set server to maint')
|
||||||
return res.sendStatus(204)
|
return res.sendStatus(204)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -407,7 +407,7 @@ if (!module.parent) {
|
||||||
if (error) {
|
if (error) {
|
||||||
logger.fatal({ error }, `Error starting CLSI on ${host}:${port}`)
|
logger.fatal({ error }, `Error starting CLSI on ${host}:${port}`)
|
||||||
} else {
|
} else {
|
||||||
logger.info(`CLSI starting up, listening on ${host}:${port}`)
|
logger.debug(`CLSI starting up, listening on ${host}:${port}`)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -415,14 +415,16 @@ if (!module.parent) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
return logger.info(`Load tcp agent listening on load port ${loadTcpPort}`)
|
return logger.debug(`Load tcp agent listening on load port ${loadTcpPort}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
loadHttpServer.listen(loadHttpPort, host, function (error) {
|
loadHttpServer.listen(loadHttpPort, host, function (error) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
return logger.info(`Load http agent listening on load port ${loadHttpPort}`)
|
return logger.debug(
|
||||||
|
`Load http agent listening on load port ${loadHttpPort}`
|
||||||
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ if ((Settings.clsi != null ? Settings.clsi.dockerRunner : undefined) === true) {
|
||||||
} else {
|
} else {
|
||||||
commandRunnerPath = './LocalCommandRunner'
|
commandRunnerPath = './LocalCommandRunner'
|
||||||
}
|
}
|
||||||
logger.info({ commandRunnerPath }, 'selecting command runner for clsi')
|
logger.debug({ commandRunnerPath }, 'selecting command runner for clsi')
|
||||||
const CommandRunner = require(commandRunnerPath)
|
const CommandRunner = require(commandRunnerPath)
|
||||||
|
|
||||||
module.exports = CommandRunner
|
module.exports = CommandRunner
|
||||||
|
|
|
@ -72,7 +72,7 @@ module.exports = CompileController = {
|
||||||
status = `validation-${error.validate}`
|
status = `validation-${error.validate}`
|
||||||
} else if (error != null ? error.timedout : undefined) {
|
} else if (error != null ? error.timedout : undefined) {
|
||||||
status = 'timedout'
|
status = 'timedout'
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ err: error, project_id: request.project_id },
|
{ err: error, project_id: request.project_id },
|
||||||
'timeout running compile'
|
'timeout running compile'
|
||||||
)
|
)
|
||||||
|
@ -245,7 +245,7 @@ module.exports = CompileController = {
|
||||||
if (image && !isImageNameAllowed(image)) {
|
if (image && !isImageNameAllowed(image)) {
|
||||||
return res.status(400).send('invalid image')
|
return res.status(400).send('invalid image')
|
||||||
}
|
}
|
||||||
logger.log({ image, file, project_id }, 'word count request')
|
logger.debug({ image, file, project_id }, 'word count request')
|
||||||
|
|
||||||
return CompileManager.wordcount(
|
return CompileManager.wordcount(
|
||||||
project_id,
|
project_id,
|
||||||
|
|
|
@ -69,7 +69,7 @@ function doCompile(request, callback) {
|
||||||
COMPILE_TIME_BUCKETS
|
COMPILE_TIME_BUCKETS
|
||||||
)
|
)
|
||||||
const timer = new Metrics.Timer('write-to-disk', 1, request.metricsOpts)
|
const timer = new Metrics.Timer('write-to-disk', 1, request.metricsOpts)
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ projectId: request.project_id, userId: request.user_id },
|
{ projectId: request.project_id, userId: request.user_id },
|
||||||
'syncing resources to disk'
|
'syncing resources to disk'
|
||||||
)
|
)
|
||||||
|
@ -95,7 +95,7 @@ function doCompile(request, callback) {
|
||||||
)
|
)
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{
|
{
|
||||||
projectId: request.project_id,
|
projectId: request.project_id,
|
||||||
userId: request.user_id,
|
userId: request.user_id,
|
||||||
|
@ -257,7 +257,7 @@ function doCompile(request, callback) {
|
||||||
Metrics.gauge('load-avg', loadavg[0])
|
Metrics.gauge('load-avg', loadavg[0])
|
||||||
}
|
}
|
||||||
const ts = timer.done()
|
const ts = timer.done()
|
||||||
logger.log(
|
logger.debug(
|
||||||
{
|
{
|
||||||
projectId: request.project_id,
|
projectId: request.project_id,
|
||||||
userId: request.user_id,
|
userId: request.user_id,
|
||||||
|
@ -498,7 +498,10 @@ function syncFromPdf(projectId, userId, page, h, v, imageName, callback) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
logger.log({ projectId, userId, page, h, v, stdout }, 'synctex pdf output')
|
logger.debug(
|
||||||
|
{ projectId, userId, page, h, v, stdout },
|
||||||
|
'synctex pdf output'
|
||||||
|
)
|
||||||
callback(null, SynctexOutputParser.parseEditOutput(stdout, baseDir))
|
callback(null, SynctexOutputParser.parseEditOutput(stdout, baseDir))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -561,7 +564,7 @@ function _runSynctex(projectId, userId, command, imageName, callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function wordcount(projectId, userId, filename, image, callback) {
|
function wordcount(projectId, userId, filename, image, callback) {
|
||||||
logger.log({ projectId, userId, filename, image }, 'running wordcount')
|
logger.debug({ projectId, userId, filename, image }, 'running wordcount')
|
||||||
const filePath = `$COMPILE_DIR/${filename}`
|
const filePath = `$COMPILE_DIR/${filename}`
|
||||||
const command = [
|
const command = [
|
||||||
'texcount',
|
'texcount',
|
||||||
|
@ -607,7 +610,7 @@ function wordcount(projectId, userId, filename, image, callback) {
|
||||||
return callback(err)
|
return callback(err)
|
||||||
}
|
}
|
||||||
const results = _parseWordcountFromOutput(stdout)
|
const results = _parseWordcountFromOutput(stdout)
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ projectId, userId, wordcount: results },
|
{ projectId, userId, wordcount: results },
|
||||||
'word count results'
|
'word count results'
|
||||||
)
|
)
|
||||||
|
|
|
@ -10,7 +10,7 @@ const Path = require('path')
|
||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
|
|
||||||
const ONE_HOUR_IN_MS = 60 * 60 * 1000
|
const ONE_HOUR_IN_MS = 60 * 60 * 1000
|
||||||
logger.info('using docker runner')
|
logger.debug('using docker runner')
|
||||||
|
|
||||||
function usingSiblingContainers() {
|
function usingSiblingContainers() {
|
||||||
return (
|
return (
|
||||||
|
@ -36,7 +36,7 @@ const DockerRunner = {
|
||||||
) {
|
) {
|
||||||
if (usingSiblingContainers()) {
|
if (usingSiblingContainers()) {
|
||||||
const _newPath = Settings.path.sandboxedCompilesHostDir
|
const _newPath = Settings.path.sandboxedCompilesHostDir
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ path: _newPath },
|
{ path: _newPath },
|
||||||
'altering bind path for sibling containers'
|
'altering bind path for sibling containers'
|
||||||
)
|
)
|
||||||
|
@ -85,14 +85,14 @@ const DockerRunner = {
|
||||||
|
|
||||||
// logOptions = _.clone(options)
|
// logOptions = _.clone(options)
|
||||||
// logOptions?.HostConfig?.SecurityOpt = "secomp used, removed in logging"
|
// logOptions?.HostConfig?.SecurityOpt = "secomp used, removed in logging"
|
||||||
logger.log({ projectId }, 'running docker container')
|
logger.debug({ projectId }, 'running docker container')
|
||||||
DockerRunner._runAndWaitForContainer(
|
DockerRunner._runAndWaitForContainer(
|
||||||
options,
|
options,
|
||||||
volumes,
|
volumes,
|
||||||
timeout,
|
timeout,
|
||||||
(error, output) => {
|
(error, output) => {
|
||||||
if (error && error.statusCode === 500) {
|
if (error && error.statusCode === 500) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ err: error, projectId },
|
{ err: error, projectId },
|
||||||
'error running container so destroying and retrying'
|
'error running container so destroying and retrying'
|
||||||
)
|
)
|
||||||
|
@ -118,7 +118,7 @@ const DockerRunner = {
|
||||||
},
|
},
|
||||||
|
|
||||||
kill(containerId, callback) {
|
kill(containerId, callback) {
|
||||||
logger.log({ containerId }, 'sending kill signal to container')
|
logger.debug({ containerId }, 'sending kill signal to container')
|
||||||
const container = dockerode.getContainer(containerId)
|
const container = dockerode.getContainer(containerId)
|
||||||
container.kill(error => {
|
container.kill(error => {
|
||||||
if (
|
if (
|
||||||
|
@ -193,7 +193,7 @@ const DockerRunner = {
|
||||||
if (options != null && options.HostConfig != null) {
|
if (options != null && options.HostConfig != null) {
|
||||||
options.HostConfig.SecurityOpt = null
|
options.HostConfig.SecurityOpt = null
|
||||||
}
|
}
|
||||||
logger.log({ exitCode, options }, 'docker container has exited')
|
logger.debug({ exitCode, options }, 'docker container has exited')
|
||||||
callbackIfFinished()
|
callbackIfFinished()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -352,7 +352,7 @@ const DockerRunner = {
|
||||||
callback = _.once(callback)
|
callback = _.once(callback)
|
||||||
const { name } = options
|
const { name } = options
|
||||||
|
|
||||||
logger.log({ container_name: name }, 'starting container')
|
logger.debug({ container_name: name }, 'starting container')
|
||||||
const container = dockerode.getContainer(name)
|
const container = dockerode.getContainer(name)
|
||||||
|
|
||||||
function createAndStartContainer() {
|
function createAndStartContainer() {
|
||||||
|
@ -412,7 +412,7 @@ const DockerRunner = {
|
||||||
attachStartCallback()
|
attachStartCallback()
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.log({ containerId }, 'attached to container')
|
logger.debug({ containerId }, 'attached to container')
|
||||||
|
|
||||||
const MAX_OUTPUT = 1024 * 1024 // limit output to 1MB
|
const MAX_OUTPUT = 1024 * 1024 // limit output to 1MB
|
||||||
function createStringOutputStream(name) {
|
function createStringOutputStream(name) {
|
||||||
|
@ -469,13 +469,13 @@ const DockerRunner = {
|
||||||
let timedOut = false
|
let timedOut = false
|
||||||
const timeoutId = setTimeout(() => {
|
const timeoutId = setTimeout(() => {
|
||||||
timedOut = true
|
timedOut = true
|
||||||
logger.log({ containerId }, 'timeout reached, killing container')
|
logger.debug({ containerId }, 'timeout reached, killing container')
|
||||||
container.kill(err => {
|
container.kill(err => {
|
||||||
logger.warn({ err, containerId }, 'failed to kill container')
|
logger.warn({ err, containerId }, 'failed to kill container')
|
||||||
})
|
})
|
||||||
}, timeout)
|
}, timeout)
|
||||||
|
|
||||||
logger.log({ containerId }, 'waiting for docker container')
|
logger.debug({ containerId }, 'waiting for docker container')
|
||||||
container.wait((error, res) => {
|
container.wait((error, res) => {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
clearTimeout(timeoutId)
|
clearTimeout(timeoutId)
|
||||||
|
@ -483,13 +483,13 @@ const DockerRunner = {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
if (timedOut) {
|
if (timedOut) {
|
||||||
logger.log({ containerId }, 'docker container timed out')
|
logger.debug({ containerId }, 'docker container timed out')
|
||||||
error = new Error('container timed out')
|
error = new Error('container timed out')
|
||||||
error.timedout = true
|
error.timedout = true
|
||||||
callback(error)
|
callback(error)
|
||||||
} else {
|
} else {
|
||||||
clearTimeout(timeoutId)
|
clearTimeout(timeoutId)
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ containerId, exitCode: res.StatusCode },
|
{ containerId, exitCode: res.StatusCode },
|
||||||
'docker container returned'
|
'docker container returned'
|
||||||
)
|
)
|
||||||
|
@ -518,7 +518,7 @@ const DockerRunner = {
|
||||||
},
|
},
|
||||||
|
|
||||||
_destroyContainer(containerId, shouldForce, callback) {
|
_destroyContainer(containerId, shouldForce, callback) {
|
||||||
logger.log({ containerId }, 'destroying docker container')
|
logger.debug({ containerId }, 'destroying docker container')
|
||||||
const container = dockerode.getContainer(containerId)
|
const container = dockerode.getContainer(containerId)
|
||||||
container.remove({ force: shouldForce === true, v: true }, error => {
|
container.remove({ force: shouldForce === true, v: true }, error => {
|
||||||
if (error != null && error.statusCode === 404) {
|
if (error != null && error.statusCode === 404) {
|
||||||
|
@ -531,7 +531,7 @@ const DockerRunner = {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
logger.error({ err: error, containerId }, 'error destroying container')
|
logger.error({ err: error, containerId }, 'error destroying container')
|
||||||
} else {
|
} else {
|
||||||
logger.log({ containerId }, 'destroyed container')
|
logger.debug({ containerId }, 'destroyed container')
|
||||||
}
|
}
|
||||||
callback(error)
|
callback(error)
|
||||||
})
|
})
|
||||||
|
@ -548,7 +548,7 @@ const DockerRunner = {
|
||||||
const age = now - created
|
const age = now - created
|
||||||
const maxAge = DockerRunner.MAX_CONTAINER_AGE
|
const maxAge = DockerRunner.MAX_CONTAINER_AGE
|
||||||
const ttl = maxAge - age
|
const ttl = maxAge - age
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ containerName: name, created, now, age, maxAge, ttl },
|
{ containerName: name, created, now, age, maxAge, ttl },
|
||||||
'checking whether to destroy container'
|
'checking whether to destroy container'
|
||||||
)
|
)
|
||||||
|
@ -579,7 +579,7 @@ const DockerRunner = {
|
||||||
},
|
},
|
||||||
|
|
||||||
startContainerMonitor() {
|
startContainerMonitor() {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ maxAge: DockerRunner.MAX_CONTAINER_AGE },
|
{ maxAge: DockerRunner.MAX_CONTAINER_AGE },
|
||||||
'starting container expiry'
|
'starting container expiry'
|
||||||
)
|
)
|
||||||
|
|
|
@ -32,7 +32,7 @@ module.exports = DraftModeManager = {
|
||||||
return callback()
|
return callback()
|
||||||
}
|
}
|
||||||
const modified_content = DraftModeManager._injectDraftOption(content)
|
const modified_content = DraftModeManager._injectDraftOption(content)
|
||||||
logger.log(
|
logger.debug(
|
||||||
{
|
{
|
||||||
content: content.slice(0, 1024), // \documentclass is normally v near the top
|
content: content.slice(0, 1024), // \documentclass is normally v near the top
|
||||||
modified_content: modified_content.slice(0, 1024),
|
modified_content: modified_content.slice(0, 1024),
|
||||||
|
|
|
@ -51,7 +51,7 @@ module.exports = LatexRunner = {
|
||||||
timeout = 60000
|
timeout = 60000
|
||||||
} // milliseconds
|
} // milliseconds
|
||||||
|
|
||||||
logger.log(
|
logger.debug(
|
||||||
{
|
{
|
||||||
directory,
|
directory,
|
||||||
compiler,
|
compiler,
|
||||||
|
@ -169,7 +169,7 @@ module.exports = LatexRunner = {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
const id = `${project_id}`
|
const id = `${project_id}`
|
||||||
logger.log({ id }, 'killing running compile')
|
logger.debug({ id }, 'killing running compile')
|
||||||
if (ProcessTable[id] == null) {
|
if (ProcessTable[id] == null) {
|
||||||
logger.warn({ id }, 'no such project to kill')
|
logger.warn({ id }, 'no such project to kill')
|
||||||
return callback(null)
|
return callback(null)
|
||||||
|
|
|
@ -17,7 +17,7 @@ const { spawn } = require('child_process')
|
||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
const logger = require('@overleaf/logger')
|
const logger = require('@overleaf/logger')
|
||||||
|
|
||||||
logger.info('using standard command runner')
|
logger.debug('using standard command runner')
|
||||||
|
|
||||||
module.exports = CommandRunner = {
|
module.exports = CommandRunner = {
|
||||||
run(
|
run(
|
||||||
|
@ -35,7 +35,7 @@ module.exports = CommandRunner = {
|
||||||
command = Array.from(command).map(arg =>
|
command = Array.from(command).map(arg =>
|
||||||
arg.toString().replace('$COMPILE_DIR', directory)
|
arg.toString().replace('$COMPILE_DIR', directory)
|
||||||
)
|
)
|
||||||
logger.log({ project_id, command, directory }, 'running command')
|
logger.debug({ project_id, command, directory }, 'running command')
|
||||||
logger.warn('timeouts and sandboxing are not enabled with CommandRunner')
|
logger.warn('timeouts and sandboxing are not enabled with CommandRunner')
|
||||||
|
|
||||||
// merge environment settings
|
// merge environment settings
|
||||||
|
@ -69,7 +69,7 @@ module.exports = CommandRunner = {
|
||||||
|
|
||||||
proc.on('close', function (code, signal) {
|
proc.on('close', function (code, signal) {
|
||||||
let err
|
let err
|
||||||
logger.info({ code, signal, project_id }, 'command exited')
|
logger.debug({ code, signal, project_id }, 'command exited')
|
||||||
if (signal === 'SIGTERM') {
|
if (signal === 'SIGTERM') {
|
||||||
// signal from kill method below
|
// signal from kill method below
|
||||||
err = new Error('terminated')
|
err = new Error('terminated')
|
||||||
|
|
|
@ -464,7 +464,7 @@ module.exports = OutputCacheManager = {
|
||||||
OutputCacheManager.ARCHIVE_SUBDIR,
|
OutputCacheManager.ARCHIVE_SUBDIR,
|
||||||
buildId
|
buildId
|
||||||
)
|
)
|
||||||
logger.log({ dir: archiveDir }, 'archiving log files for project')
|
logger.debug({ dir: archiveDir }, 'archiving log files for project')
|
||||||
return fse.ensureDir(archiveDir, function (err) {
|
return fse.ensureDir(archiveDir, function (err) {
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
return callback(err)
|
return callback(err)
|
||||||
|
@ -577,7 +577,7 @@ module.exports = OutputCacheManager = {
|
||||||
|
|
||||||
const removeDir = (dir, cb) =>
|
const removeDir = (dir, cb) =>
|
||||||
fse.remove(Path.join(cacheRoot, dir), function (err, result) {
|
fse.remove(Path.join(cacheRoot, dir), function (err, result) {
|
||||||
logger.log({ cache: cacheRoot, dir }, 'removed expired cache dir')
|
logger.debug({ cache: cacheRoot, dir }, 'removed expired cache dir')
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
logger.error({ err, dir }, 'cache remove error')
|
logger.error({ err, dir }, 'cache remove error')
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ module.exports = OutputFileFinder = {
|
||||||
'f',
|
'f',
|
||||||
'-print',
|
'-print',
|
||||||
]
|
]
|
||||||
logger.log({ args }, 'running find command')
|
logger.debug({ args }, 'running find command')
|
||||||
|
|
||||||
const proc = spawn('find', args)
|
const proc = spawn('find', args)
|
||||||
let stdout = ''
|
let stdout = ''
|
||||||
|
|
|
@ -71,7 +71,7 @@ module.exports = OutputFileOptimiser = {
|
||||||
}
|
}
|
||||||
const tmpOutput = dst + '.opt'
|
const tmpOutput = dst + '.opt'
|
||||||
const args = ['--linearize', '--newline-before-endstream', src, tmpOutput]
|
const args = ['--linearize', '--newline-before-endstream', src, tmpOutput]
|
||||||
logger.log({ args }, 'running qpdf command')
|
logger.debug({ args }, 'running qpdf command')
|
||||||
|
|
||||||
const timer = new Metrics.Timer('qpdf')
|
const timer = new Metrics.Timer('qpdf')
|
||||||
const proc = spawn('qpdf', args)
|
const proc = spawn('qpdf', args)
|
||||||
|
|
|
@ -121,7 +121,7 @@ module.exports = ProjectPersistenceManager = {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
logger.log({ project_ids }, 'clearing expired projects')
|
logger.debug({ project_ids }, 'clearing expired projects')
|
||||||
const jobs = Array.from(project_ids || []).map(project_id =>
|
const jobs = Array.from(project_ids || []).map(project_id =>
|
||||||
(
|
(
|
||||||
project_id => callback =>
|
project_id => callback =>
|
||||||
|
@ -152,7 +152,7 @@ module.exports = ProjectPersistenceManager = {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
logger.log({ project_id, user_id }, 'clearing project for user')
|
logger.debug({ project_id, user_id }, 'clearing project for user')
|
||||||
return CompileManager.clearProject(project_id, user_id, function (error) {
|
return CompileManager.clearProject(project_id, user_id, function (error) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
|
@ -173,7 +173,7 @@ module.exports = ProjectPersistenceManager = {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
logger.log({ project_id }, 'clearing project from cache')
|
logger.debug({ project_id }, 'clearing project from cache')
|
||||||
return UrlCache.clearProject(project_id, function (error) {
|
return UrlCache.clearProject(project_id, function (error) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
logger.err({ error, project_id }, 'error clearing project from cache')
|
logger.err({ error, project_id }, 'error clearing project from cache')
|
||||||
|
@ -212,7 +212,7 @@ module.exports = ProjectPersistenceManager = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ EXPIRY_TIMEOUT: ProjectPersistenceManager.EXPIRY_TIMEOUT },
|
{ EXPIRY_TIMEOUT: ProjectPersistenceManager.EXPIRY_TIMEOUT },
|
||||||
'project assets kept timeout'
|
'project assets kept timeout'
|
||||||
)
|
)
|
||||||
|
|
|
@ -26,7 +26,7 @@ module.exports = {
|
||||||
const stateFile = Path.join(basePath, this.SYNC_STATE_FILE)
|
const stateFile = Path.join(basePath, this.SYNC_STATE_FILE)
|
||||||
if (state == null) {
|
if (state == null) {
|
||||||
// remove the file if no state passed in
|
// remove the file if no state passed in
|
||||||
logger.log({ state, basePath }, 'clearing sync state')
|
logger.debug({ state, basePath }, 'clearing sync state')
|
||||||
fs.unlink(stateFile, function (err) {
|
fs.unlink(stateFile, function (err) {
|
||||||
if (err && err.code !== 'ENOENT') {
|
if (err && err.code !== 'ENOENT') {
|
||||||
return callback(err)
|
return callback(err)
|
||||||
|
@ -35,7 +35,7 @@ module.exports = {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
logger.log({ state, basePath }, 'writing sync state')
|
logger.debug({ state, basePath }, 'writing sync state')
|
||||||
const resourceList = resources.map(resource => resource.path)
|
const resourceList = resources.map(resource => resource.path)
|
||||||
fs.writeFile(
|
fs.writeFile(
|
||||||
stateFile,
|
stateFile,
|
||||||
|
@ -67,7 +67,7 @@ module.exports = {
|
||||||
const resourceList = array.slice(0, adjustedLength - 1)
|
const resourceList = array.slice(0, adjustedLength - 1)
|
||||||
const oldState = array[adjustedLength - 1]
|
const oldState = array[adjustedLength - 1]
|
||||||
const newState = `stateHash:${state}`
|
const newState = `stateHash:${state}`
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ state, oldState, basePath, stateMatches: newState === oldState },
|
{ state, oldState, basePath, stateMatches: newState === oldState },
|
||||||
'checking sync state'
|
'checking sync state'
|
||||||
)
|
)
|
||||||
|
|
|
@ -32,7 +32,7 @@ module.exports = ResourceWriter = {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
if (request.syncType === 'incremental') {
|
if (request.syncType === 'incremental') {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id: request.project_id, user_id: request.user_id },
|
{ project_id: request.project_id, user_id: request.user_id },
|
||||||
'incremental sync'
|
'incremental sync'
|
||||||
)
|
)
|
||||||
|
@ -77,7 +77,7 @@ module.exports = ResourceWriter = {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id: request.project_id, user_id: request.user_id },
|
{ project_id: request.project_id, user_id: request.user_id },
|
||||||
'full sync'
|
'full sync'
|
||||||
)
|
)
|
||||||
|
@ -160,7 +160,7 @@ module.exports = ResourceWriter = {
|
||||||
if (err.code === 'EEXIST') {
|
if (err.code === 'EEXIST') {
|
||||||
return callback()
|
return callback()
|
||||||
} else {
|
} else {
|
||||||
logger.log({ err, dir: basePath }, 'error creating directory')
|
logger.debug({ err, dir: basePath }, 'error creating directory')
|
||||||
return callback(err)
|
return callback(err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -29,7 +29,10 @@ module.exports = TikzManager = {
|
||||||
}
|
}
|
||||||
for (const resource of Array.from(resources)) {
|
for (const resource of Array.from(resources)) {
|
||||||
if (resource.path === 'output.tex') {
|
if (resource.path === 'output.tex') {
|
||||||
logger.log({ compileDir, mainFile }, 'output.tex already in resources')
|
logger.debug(
|
||||||
|
{ compileDir, mainFile },
|
||||||
|
'output.tex already in resources'
|
||||||
|
)
|
||||||
return callback(null, false)
|
return callback(null, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +58,7 @@ module.exports = TikzManager = {
|
||||||
: undefined) >= 0
|
: undefined) >= 0
|
||||||
const usesPsTool =
|
const usesPsTool =
|
||||||
(content != null ? content.indexOf('{pstool}') : undefined) >= 0
|
(content != null ? content.indexOf('{pstool}') : undefined) >= 0
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ compileDir, mainFile, usesTikzExternalize, usesPsTool },
|
{ compileDir, mainFile, usesTikzExternalize, usesPsTool },
|
||||||
'checked for packages needing main file as output.tex'
|
'checked for packages needing main file as output.tex'
|
||||||
)
|
)
|
||||||
|
@ -82,7 +85,7 @@ module.exports = TikzManager = {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ compileDir, mainFile },
|
{ compileDir, mainFile },
|
||||||
'copied file to output.tex as project uses packages which require it'
|
'copied file to output.tex as project uses packages which require it'
|
||||||
)
|
)
|
||||||
|
|
|
@ -61,7 +61,7 @@ module.exports = UrlFetcher = {
|
||||||
3 * oneMinute
|
3 * oneMinute
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.log({ url, filePath }, 'started downloading url to cache')
|
logger.debug({ url, filePath }, 'started downloading url to cache')
|
||||||
const urlStream = request.get({ url, timeout: oneMinute })
|
const urlStream = request.get({ url, timeout: oneMinute })
|
||||||
urlStream.pause() // stop data flowing until we are ready
|
urlStream.pause() // stop data flowing until we are ready
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ module.exports = UrlFetcher = {
|
||||||
})
|
})
|
||||||
|
|
||||||
urlStream.on('end', () =>
|
urlStream.on('end', () =>
|
||||||
logger.log({ url, filePath }, 'finished downloading file into cache')
|
logger.debug({ url, filePath }, 'finished downloading file into cache')
|
||||||
)
|
)
|
||||||
|
|
||||||
return urlStream.on('response', function (res) {
|
return urlStream.on('response', function (res) {
|
||||||
|
@ -97,7 +97,7 @@ module.exports = UrlFetcher = {
|
||||||
})
|
})
|
||||||
|
|
||||||
fileStream.on('finish', function () {
|
fileStream.on('finish', function () {
|
||||||
logger.log({ url, filePath }, 'finished writing file into cache')
|
logger.debug({ url, filePath }, 'finished writing file into cache')
|
||||||
fs.rename(atomicWrite, filePath, error => {
|
fs.rename(atomicWrite, filePath, error => {
|
||||||
if (error) {
|
if (error) {
|
||||||
fs.unlink(atomicWrite, () => callbackOnce(error))
|
fs.unlink(atomicWrite, () => callbackOnce(error))
|
||||||
|
@ -108,7 +108,7 @@ module.exports = UrlFetcher = {
|
||||||
})
|
})
|
||||||
|
|
||||||
fileStream.on('pipe', () =>
|
fileStream.on('pipe', () =>
|
||||||
logger.log({ url, filePath }, 'piping into filestream')
|
logger.debug({ url, filePath }, 'piping into filestream')
|
||||||
)
|
)
|
||||||
|
|
||||||
urlStream.pipe(fileStream)
|
urlStream.pipe(fileStream)
|
||||||
|
|
|
@ -57,7 +57,9 @@ if (!module.parent) {
|
||||||
logger.fatal({ err }, `Cannot bind to ${host}:${port}. Exiting.`)
|
logger.fatal({ err }, `Cannot bind to ${host}:${port}. Exiting.`)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
return logger.info(`contacts starting up, listening on ${host}:${port}`)
|
return logger.debug(
|
||||||
|
`contacts starting up, listening on ${host}:${port}`
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
|
|
@ -23,7 +23,7 @@ module.exports = HttpController = {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.log({ user_id, contact_id }, 'adding contact')
|
logger.debug({ user_id, contact_id }, 'adding contact')
|
||||||
|
|
||||||
return ContactManager.touchContact(user_id, contact_id, function (error) {
|
return ContactManager.touchContact(user_id, contact_id, function (error) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
|
@ -50,7 +50,7 @@ module.exports = HttpController = {
|
||||||
}
|
}
|
||||||
limit = Math.min(limit, HttpController.CONTACT_LIMIT)
|
limit = Math.min(limit, HttpController.CONTACT_LIMIT)
|
||||||
|
|
||||||
logger.log({ user_id }, 'getting contacts')
|
logger.debug({ user_id }, 'getting contacts')
|
||||||
|
|
||||||
return ContactManager.getContacts(user_id, function (error, contact_dict) {
|
return ContactManager.getContacts(user_id, function (error, contact_dict) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
|
|
|
@ -2,7 +2,13 @@ const SandboxedModule = require('sandboxed-module')
|
||||||
|
|
||||||
SandboxedModule.configure({
|
SandboxedModule.configure({
|
||||||
requires: {
|
requires: {
|
||||||
'@overleaf/logger': { log() {} },
|
'@overleaf/logger': {
|
||||||
|
debug() {},
|
||||||
|
info() {},
|
||||||
|
log() {},
|
||||||
|
warn() {},
|
||||||
|
error() {},
|
||||||
|
},
|
||||||
'@overleaf/metrics': { timeAsyncMethod() {} },
|
'@overleaf/metrics': { timeAsyncMethod() {} },
|
||||||
},
|
},
|
||||||
globals: { Buffer, console, process },
|
globals: { Buffer, console, process },
|
||||||
|
|
|
@ -109,7 +109,9 @@ if (!module.parent) {
|
||||||
logger.fatal({ err }, `Cannot bind to ${host}:${port}. Exiting.`)
|
logger.fatal({ err }, `Cannot bind to ${host}:${port}. Exiting.`)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
return logger.info(`Docstore starting up, listening on ${host}:${port}`)
|
return logger.debug(
|
||||||
|
`Docstore starting up, listening on ${host}:${port}`
|
||||||
|
)
|
||||||
})
|
})
|
||||||
server.timeout = 120000
|
server.timeout = 120000
|
||||||
server.keepAliveTimeout = 5000
|
server.keepAliveTimeout = 5000
|
||||||
|
|
|
@ -70,7 +70,7 @@ async function archiveDocById(projectId, docId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function archiveDoc(projectId, doc) {
|
async function archiveDoc(projectId, doc) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id: projectId, doc_id: doc._id },
|
{ project_id: projectId, doc_id: doc._id },
|
||||||
'sending doc to persistor'
|
'sending doc to persistor'
|
||||||
)
|
)
|
||||||
|
@ -154,7 +154,7 @@ async function getDoc(projectId, docId) {
|
||||||
|
|
||||||
// get the doc and unarchive it to mongo
|
// get the doc and unarchive it to mongo
|
||||||
async function unarchiveDoc(projectId, docId) {
|
async function unarchiveDoc(projectId, docId) {
|
||||||
logger.log({ projectId, docId }, 'getting doc from persistor')
|
logger.debug({ projectId, docId }, 'getting doc from persistor')
|
||||||
const mongoDoc = await MongoManager.findDoc(projectId, docId, {
|
const mongoDoc = await MongoManager.findDoc(projectId, docId, {
|
||||||
inS3: 1,
|
inS3: 1,
|
||||||
rev: 1,
|
rev: 1,
|
||||||
|
|
|
@ -289,7 +289,10 @@ module.exports = DocManager = {
|
||||||
if (updateRanges) {
|
if (updateRanges) {
|
||||||
update.ranges = ranges
|
update.ranges = ranges
|
||||||
}
|
}
|
||||||
logger.log({ project_id, doc_id }, 'updating doc lines and ranges')
|
logger.debug(
|
||||||
|
{ project_id, doc_id },
|
||||||
|
'updating doc lines and ranges'
|
||||||
|
)
|
||||||
|
|
||||||
modified = true
|
modified = true
|
||||||
rev += 1 // rev will be incremented in mongo by MongoManager.upsertIntoDocCollection
|
rev += 1 // rev will be incremented in mongo by MongoManager.upsertIntoDocCollection
|
||||||
|
@ -300,7 +303,7 @@ module.exports = DocManager = {
|
||||||
cb
|
cb
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, doc_id },
|
{ project_id, doc_id },
|
||||||
'doc lines have not changed - not updating'
|
'doc lines have not changed - not updating'
|
||||||
)
|
)
|
||||||
|
@ -310,7 +313,7 @@ module.exports = DocManager = {
|
||||||
|
|
||||||
const updateVersionIfNeeded = function (cb) {
|
const updateVersionIfNeeded = function (cb) {
|
||||||
if (updateVersion) {
|
if (updateVersion) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{
|
{
|
||||||
project_id,
|
project_id,
|
||||||
doc_id,
|
doc_id,
|
||||||
|
@ -322,7 +325,7 @@ module.exports = DocManager = {
|
||||||
modified = true
|
modified = true
|
||||||
return MongoManager.setDocVersion(doc_id, version, cb)
|
return MongoManager.setDocVersion(doc_id, version, cb)
|
||||||
} else {
|
} else {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, doc_id, version },
|
{ project_id, doc_id, version },
|
||||||
'doc version has not changed - not updating'
|
'doc version has not changed - not updating'
|
||||||
)
|
)
|
||||||
|
|
|
@ -31,7 +31,7 @@ module.exports = {
|
||||||
url,
|
url,
|
||||||
timeout: 3000,
|
timeout: 3000,
|
||||||
})
|
})
|
||||||
logger.log({ lines, url, doc_id, project_id }, 'running health check')
|
logger.debug({ lines, url, doc_id, project_id }, 'running health check')
|
||||||
const jobs = [
|
const jobs = [
|
||||||
function (cb) {
|
function (cb) {
|
||||||
const opts = getOpts()
|
const opts = getOpts()
|
||||||
|
|
|
@ -8,12 +8,12 @@ const Settings = require('@overleaf/settings')
|
||||||
function getDoc(req, res, next) {
|
function getDoc(req, res, next) {
|
||||||
const { doc_id: docId, project_id: projectId } = req.params
|
const { doc_id: docId, project_id: projectId } = req.params
|
||||||
const includeDeleted = req.query.include_deleted === 'true'
|
const includeDeleted = req.query.include_deleted === 'true'
|
||||||
logger.log({ projectId, docId }, 'getting doc')
|
logger.debug({ projectId, docId }, 'getting doc')
|
||||||
DocManager.getFullDoc(projectId, docId, function (error, doc) {
|
DocManager.getFullDoc(projectId, docId, function (error, doc) {
|
||||||
if (error) {
|
if (error) {
|
||||||
return next(error)
|
return next(error)
|
||||||
}
|
}
|
||||||
logger.log({ docId, projectId }, 'got doc')
|
logger.debug({ docId, projectId }, 'got doc')
|
||||||
if (doc == null) {
|
if (doc == null) {
|
||||||
res.sendStatus(404)
|
res.sendStatus(404)
|
||||||
} else if (doc.deleted && !includeDeleted) {
|
} else if (doc.deleted && !includeDeleted) {
|
||||||
|
@ -26,7 +26,7 @@ function getDoc(req, res, next) {
|
||||||
|
|
||||||
function peekDoc(req, res, next) {
|
function peekDoc(req, res, next) {
|
||||||
const { doc_id: docId, project_id: projectId } = req.params
|
const { doc_id: docId, project_id: projectId } = req.params
|
||||||
logger.log({ projectId, docId }, 'peeking doc')
|
logger.debug({ projectId, docId }, 'peeking doc')
|
||||||
DocManager.peekDoc(projectId, docId, function (error, doc) {
|
DocManager.peekDoc(projectId, docId, function (error, doc) {
|
||||||
if (error) {
|
if (error) {
|
||||||
return next(error)
|
return next(error)
|
||||||
|
@ -52,7 +52,7 @@ function isDocDeleted(req, res, next) {
|
||||||
|
|
||||||
function getRawDoc(req, res, next) {
|
function getRawDoc(req, res, next) {
|
||||||
const { doc_id: docId, project_id: projectId } = req.params
|
const { doc_id: docId, project_id: projectId } = req.params
|
||||||
logger.log({ projectId, docId }, 'getting raw doc')
|
logger.debug({ projectId, docId }, 'getting raw doc')
|
||||||
DocManager.getDocLines(projectId, docId, function (error, doc) {
|
DocManager.getDocLines(projectId, docId, function (error, doc) {
|
||||||
if (error) {
|
if (error) {
|
||||||
return next(error)
|
return next(error)
|
||||||
|
@ -68,7 +68,7 @@ function getRawDoc(req, res, next) {
|
||||||
|
|
||||||
function getAllDocs(req, res, next) {
|
function getAllDocs(req, res, next) {
|
||||||
const { project_id: projectId } = req.params
|
const { project_id: projectId } = req.params
|
||||||
logger.log({ projectId }, 'getting all docs')
|
logger.debug({ projectId }, 'getting all docs')
|
||||||
DocManager.getAllNonDeletedDocs(
|
DocManager.getAllNonDeletedDocs(
|
||||||
projectId,
|
projectId,
|
||||||
{ lines: true, rev: true },
|
{ lines: true, rev: true },
|
||||||
|
@ -86,7 +86,7 @@ function getAllDocs(req, res, next) {
|
||||||
|
|
||||||
function getAllDeletedDocs(req, res, next) {
|
function getAllDeletedDocs(req, res, next) {
|
||||||
const { project_id: projectId } = req.params
|
const { project_id: projectId } = req.params
|
||||||
logger.log({ projectId }, 'getting all deleted docs')
|
logger.debug({ projectId }, 'getting all deleted docs')
|
||||||
DocManager.getAllDeletedDocs(
|
DocManager.getAllDeletedDocs(
|
||||||
projectId,
|
projectId,
|
||||||
{ name: true, deletedAt: true },
|
{ name: true, deletedAt: true },
|
||||||
|
@ -107,7 +107,7 @@ function getAllDeletedDocs(req, res, next) {
|
||||||
|
|
||||||
function getAllRanges(req, res, next) {
|
function getAllRanges(req, res, next) {
|
||||||
const { project_id: projectId } = req.params
|
const { project_id: projectId } = req.params
|
||||||
logger.log({ projectId }, 'getting all ranges')
|
logger.debug({ projectId }, 'getting all ranges')
|
||||||
DocManager.getAllNonDeletedDocs(
|
DocManager.getAllNonDeletedDocs(
|
||||||
projectId,
|
projectId,
|
||||||
{ ranges: true },
|
{ ranges: true },
|
||||||
|
@ -154,7 +154,7 @@ function updateDoc(req, res, next) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.log({ projectId, docId }, 'got http request to update doc')
|
logger.debug({ projectId, docId }, 'got http request to update doc')
|
||||||
DocManager.updateDoc(
|
DocManager.updateDoc(
|
||||||
projectId,
|
projectId,
|
||||||
docId,
|
docId,
|
||||||
|
@ -175,7 +175,7 @@ function updateDoc(req, res, next) {
|
||||||
|
|
||||||
function patchDoc(req, res, next) {
|
function patchDoc(req, res, next) {
|
||||||
const { doc_id: docId, project_id: projectId } = req.params
|
const { doc_id: docId, project_id: projectId } = req.params
|
||||||
logger.log({ projectId, docId }, 'patching doc')
|
logger.debug({ projectId, docId }, 'patching doc')
|
||||||
|
|
||||||
const allowedFields = ['deleted', 'deletedAt', 'name']
|
const allowedFields = ['deleted', 'deletedAt', 'name']
|
||||||
const meta = {}
|
const meta = {}
|
||||||
|
@ -226,7 +226,7 @@ function _buildDocsArrayView(projectId, docs) {
|
||||||
|
|
||||||
function archiveAllDocs(req, res, next) {
|
function archiveAllDocs(req, res, next) {
|
||||||
const { project_id: projectId } = req.params
|
const { project_id: projectId } = req.params
|
||||||
logger.log({ projectId }, 'archiving all docs')
|
logger.debug({ projectId }, 'archiving all docs')
|
||||||
DocArchive.archiveAllDocs(projectId, function (error) {
|
DocArchive.archiveAllDocs(projectId, function (error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
return next(error)
|
return next(error)
|
||||||
|
@ -237,7 +237,7 @@ function archiveAllDocs(req, res, next) {
|
||||||
|
|
||||||
function archiveDoc(req, res, next) {
|
function archiveDoc(req, res, next) {
|
||||||
const { doc_id: docId, project_id: projectId } = req.params
|
const { doc_id: docId, project_id: projectId } = req.params
|
||||||
logger.log({ projectId, docId }, 'archiving a doc')
|
logger.debug({ projectId, docId }, 'archiving a doc')
|
||||||
DocArchive.archiveDocById(projectId, docId, function (error) {
|
DocArchive.archiveDocById(projectId, docId, function (error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
return next(error)
|
return next(error)
|
||||||
|
@ -248,7 +248,7 @@ function archiveDoc(req, res, next) {
|
||||||
|
|
||||||
function unArchiveAllDocs(req, res, next) {
|
function unArchiveAllDocs(req, res, next) {
|
||||||
const { project_id: projectId } = req.params
|
const { project_id: projectId } = req.params
|
||||||
logger.log({ projectId }, 'unarchiving all docs')
|
logger.debug({ projectId }, 'unarchiving all docs')
|
||||||
DocArchive.unArchiveAllDocs(projectId, function (err) {
|
DocArchive.unArchiveAllDocs(projectId, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
if (err instanceof Errors.DocRevValueError) {
|
if (err instanceof Errors.DocRevValueError) {
|
||||||
|
@ -263,7 +263,7 @@ function unArchiveAllDocs(req, res, next) {
|
||||||
|
|
||||||
function destroyProject(req, res, next) {
|
function destroyProject(req, res, next) {
|
||||||
const { project_id: projectId } = req.params
|
const { project_id: projectId } = req.params
|
||||||
logger.log({ projectId }, 'destroying all docs')
|
logger.debug({ projectId }, 'destroying all docs')
|
||||||
DocArchive.destroyProject(projectId, function (error) {
|
DocArchive.destroyProject(projectId, function (error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
return next(error)
|
return next(error)
|
||||||
|
|
|
@ -15,7 +15,9 @@ chai.use(chaiAsPromised)
|
||||||
const sandbox = sinon.createSandbox()
|
const sandbox = sinon.createSandbox()
|
||||||
const stubs = {
|
const stubs = {
|
||||||
logger: {
|
logger: {
|
||||||
|
debug: sandbox.stub(),
|
||||||
log: sandbox.stub(),
|
log: sandbox.stub(),
|
||||||
|
info: sandbox.stub(),
|
||||||
warn: sandbox.stub(),
|
warn: sandbox.stub(),
|
||||||
err: sandbox.stub(),
|
err: sandbox.stub(),
|
||||||
error: sandbox.stub(),
|
error: sandbox.stub(),
|
||||||
|
|
|
@ -145,7 +145,7 @@ if (!module.parent) {
|
||||||
logger.error('Error starting Filestore', error)
|
logger.error('Error starting Filestore', error)
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
logger.info(`Filestore starting up, listening on ${host}:${port}`)
|
logger.debug(`Filestore starting up, listening on ${host}:${port}`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ mongodb
|
||||||
.waitForDb()
|
.waitForDb()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
app.listen(port, host, () =>
|
app.listen(port, host, () =>
|
||||||
logger.info(`notifications starting up, listening on ${host}:${port}`)
|
logger.debug(`notifications starting up, listening on ${host}:${port}`)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
|
|
@ -29,7 +29,7 @@ module.exports = {
|
||||||
url: `http://localhost:${port}/user/${user_id}${endPath}`,
|
url: `http://localhost:${port}/user/${user_id}${endPath}`,
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
})
|
})
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ user_id, opts: getOpts(), key: notification_key, user_id },
|
{ user_id, opts: getOpts(), key: notification_key, user_id },
|
||||||
'Health Check: running'
|
'Health Check: running'
|
||||||
)
|
)
|
||||||
|
@ -82,7 +82,7 @@ module.exports = {
|
||||||
const notification_id = body[1][0]._id
|
const notification_id = body[1][0]._id
|
||||||
notification_key = body[1][0].key
|
notification_key = body[1][0].key
|
||||||
let opts = getOpts(`/notification/${notification_id}`)
|
let opts = getOpts(`/notification/${notification_id}`)
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ notification_id, notification_key },
|
{ notification_id, notification_key },
|
||||||
'Health Check: doing cleanup'
|
'Health Check: doing cleanup'
|
||||||
)
|
)
|
||||||
|
|
|
@ -15,7 +15,7 @@ const metrics = require('@overleaf/metrics')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getUserNotifications(req, res, next) {
|
getUserNotifications(req, res, next) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ user_id: req.params.user_id },
|
{ user_id: req.params.user_id },
|
||||||
'getting user unread notifications'
|
'getting user unread notifications'
|
||||||
)
|
)
|
||||||
|
@ -30,7 +30,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
|
|
||||||
addNotification(req, res) {
|
addNotification(req, res) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ user_id: req.params.user_id, notification: req.body },
|
{ user_id: req.params.user_id, notification: req.body },
|
||||||
'adding notification'
|
'adding notification'
|
||||||
)
|
)
|
||||||
|
@ -49,7 +49,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
|
|
||||||
removeNotificationId(req, res, next) {
|
removeNotificationId(req, res, next) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{
|
{
|
||||||
user_id: req.params.user_id,
|
user_id: req.params.user_id,
|
||||||
notification_id: req.params.notification_id,
|
notification_id: req.params.notification_id,
|
||||||
|
@ -68,7 +68,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
|
|
||||||
removeNotificationKey(req, res, next) {
|
removeNotificationKey(req, res, next) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ user_id: req.params.user_id, notification_key: req.body.key },
|
{ user_id: req.params.user_id, notification_key: req.body.key },
|
||||||
'mark key notification as read'
|
'mark key notification as read'
|
||||||
)
|
)
|
||||||
|
@ -85,7 +85,7 @@ module.exports = {
|
||||||
|
|
||||||
removeNotificationByKeyOnly(req, res, next) {
|
removeNotificationByKeyOnly(req, res, next) {
|
||||||
const notification_key = req.params.key
|
const notification_key = req.params.key
|
||||||
logger.log({ notification_key }, 'mark notification as read by key only')
|
logger.debug({ notification_key }, 'mark notification as read by key only')
|
||||||
metrics.inc('removeNotificationKey')
|
metrics.inc('removeNotificationKey')
|
||||||
return Notifications.removeNotificationByKeyOnly(notification_key, err => {
|
return Notifications.removeNotificationByKeyOnly(notification_key, err => {
|
||||||
if (err) return next(err)
|
if (err) return next(err)
|
||||||
|
|
|
@ -44,7 +44,7 @@ if (!module.parent) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
return logger.info(`spelling starting up, listening on ${host}:${port}`)
|
return logger.debug(`spelling starting up, listening on ${host}:${port}`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ try {
|
||||||
const oldCache = fs.readFileSync(cacheFsPath)
|
const oldCache = fs.readFileSync(cacheFsPath)
|
||||||
cache.load(JSON.parse(oldCache))
|
cache.load(JSON.parse(oldCache))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
OError.tag(error, 'could not load the cache file', { cacheFsPath })
|
OError.tag(error, 'could not load the cache file', { cacheFsPath })
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -38,14 +38,14 @@ const cacheDump = setInterval(function () {
|
||||||
const dump = JSON.stringify(cache.dump())
|
const dump = JSON.stringify(cache.dump())
|
||||||
return fs.writeFile(cacheFsPathTmp, dump, function (err) {
|
return fs.writeFile(cacheFsPathTmp, dump, function (err) {
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
logger.log(OError.tag(err, 'error writing cache file'))
|
logger.debug(OError.tag(err, 'error writing cache file'))
|
||||||
fs.unlink(cacheFsPathTmp, () => {})
|
fs.unlink(cacheFsPathTmp, () => {})
|
||||||
} else {
|
} else {
|
||||||
fs.rename(cacheFsPathTmp, cacheFsPath, err => {
|
fs.rename(cacheFsPathTmp, cacheFsPath, err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
logger.error(OError.tag(err, 'error renaming cache file'))
|
logger.error(OError.tag(err, 'error renaming cache file'))
|
||||||
} else {
|
} else {
|
||||||
logger.log({ len: dump.length, cacheFsPath }, 'wrote cache file')
|
logger.debug({ len: dump.length, cacheFsPath }, 'wrote cache file')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ class ASpellRunner {
|
||||||
cache.set(k, v)
|
cache.set(k, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(
|
logger.debug(
|
||||||
{
|
{
|
||||||
hits,
|
hits,
|
||||||
total: words.length,
|
total: words.length,
|
||||||
|
|
|
@ -27,14 +27,14 @@ class ASpellWorker {
|
||||||
'-d',
|
'-d',
|
||||||
language,
|
language,
|
||||||
])
|
])
|
||||||
logger.info(
|
logger.debug(
|
||||||
{ process: this.pipe.pid, lang: this.language },
|
{ process: this.pipe.pid, lang: this.language },
|
||||||
'starting new aspell worker'
|
'starting new aspell worker'
|
||||||
)
|
)
|
||||||
metrics.inc('aspellWorker', 1, { status: 'start', method: this.language })
|
metrics.inc('aspellWorker', 1, { status: 'start', method: this.language })
|
||||||
this.pipe.on('exit', () => {
|
this.pipe.on('exit', () => {
|
||||||
this.state = 'killed'
|
this.state = 'killed'
|
||||||
logger.info(
|
logger.debug(
|
||||||
{ process: this.pipe.pid, lang: this.language },
|
{ process: this.pipe.pid, lang: this.language },
|
||||||
'aspell worker has exited'
|
'aspell worker has exited'
|
||||||
)
|
)
|
||||||
|
@ -201,14 +201,14 @@ class ASpellWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
shutdown(reason) {
|
shutdown(reason) {
|
||||||
logger.info({ process: this.pipe.pid, reason }, 'shutting down')
|
logger.debug({ process: this.pipe.pid, reason }, 'shutting down')
|
||||||
this.state = 'closing'
|
this.state = 'closing'
|
||||||
this.closeReason = reason
|
this.closeReason = reason
|
||||||
return this.pipe.stdin.end()
|
return this.pipe.stdin.end()
|
||||||
}
|
}
|
||||||
|
|
||||||
kill(reason) {
|
kill(reason) {
|
||||||
logger.info({ process: this.pipe.pid, reason }, 'killing')
|
logger.debug({ process: this.pipe.pid, reason }, 'killing')
|
||||||
this.closeReason = reason
|
this.closeReason = reason
|
||||||
if (this.state === 'killed') {
|
if (this.state === 'killed') {
|
||||||
return
|
return
|
||||||
|
|
|
@ -28,7 +28,7 @@ class ASpellWorkerPool {
|
||||||
|
|
||||||
create(language) {
|
create(language) {
|
||||||
if (this.PROCESS_POOL.length >= this.MAX_WORKERS) {
|
if (this.PROCESS_POOL.length >= this.MAX_WORKERS) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ maxworkers: this.MAX_WORKERS },
|
{ maxworkers: this.MAX_WORKERS },
|
||||||
'maximum number of workers already running'
|
'maximum number of workers already running'
|
||||||
)
|
)
|
||||||
|
@ -44,7 +44,7 @@ class ASpellWorkerPool {
|
||||||
clearTimeout(worker.idleTimer)
|
clearTimeout(worker.idleTimer)
|
||||||
worker.idleTimer = null
|
worker.idleTimer = null
|
||||||
}
|
}
|
||||||
logger.info(
|
logger.debug(
|
||||||
{ process: worker.pipe.pid, lang: language },
|
{ process: worker.pipe.pid, lang: language },
|
||||||
'removing aspell worker from pool'
|
'removing aspell worker from pool'
|
||||||
)
|
)
|
||||||
|
|
|
@ -26,7 +26,7 @@ module.exports = {
|
||||||
: 0
|
: 0
|
||||||
|
|
||||||
if (numberOfSuggestions > 10) {
|
if (numberOfSuggestions > 10) {
|
||||||
logger.log('health check passed')
|
logger.debug('health check passed')
|
||||||
res.sendStatus(200)
|
res.sendStatus(200)
|
||||||
} else {
|
} else {
|
||||||
logger.err(
|
logger.err(
|
||||||
|
|
|
@ -14,7 +14,7 @@ module.exports = {
|
||||||
check(req, res) {
|
check(req, res) {
|
||||||
metrics.inc('spelling-check', 0.1)
|
metrics.inc('spelling-check', 0.1)
|
||||||
const { token, wordCount } = extractCheckRequestData(req)
|
const { token, wordCount } = extractCheckRequestData(req)
|
||||||
logger.info({ token, wordCount }, 'running check')
|
logger.debug({ token, wordCount }, 'running check')
|
||||||
SpellingAPIManager.runRequest(token, req.body, function (error, result) {
|
SpellingAPIManager.runRequest(token, req.body, function (error, result) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
logger.error(
|
logger.error(
|
||||||
|
|
|
@ -87,7 +87,7 @@ app.post('/pack', function (req, res, next) {
|
||||||
if (packWorker != null) {
|
if (packWorker != null) {
|
||||||
return res.send('pack already running')
|
return res.send('pack already running')
|
||||||
} else {
|
} else {
|
||||||
logger.log('running pack')
|
logger.debug('running pack')
|
||||||
packWorker = childProcess.fork(
|
packWorker = childProcess.fork(
|
||||||
Path.join(__dirname, '/app/js/PackWorker.js'),
|
Path.join(__dirname, '/app/js/PackWorker.js'),
|
||||||
[
|
[
|
||||||
|
@ -97,7 +97,7 @@ app.post('/pack', function (req, res, next) {
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
packWorker.on('exit', function (code, signal) {
|
packWorker.on('exit', function (code, signal) {
|
||||||
logger.log({ code, signal }, 'history auto pack exited')
|
logger.debug({ code, signal }, 'history auto pack exited')
|
||||||
return (packWorker = null)
|
return (packWorker = null)
|
||||||
})
|
})
|
||||||
return res.send('pack started')
|
return res.send('pack started')
|
||||||
|
@ -142,7 +142,7 @@ if (!module.parent) {
|
||||||
'could not start track-changes server'
|
'could not start track-changes server'
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
return logger.info(
|
return logger.debug(
|
||||||
`trackchanges starting up, listening on ${host}:${port}`
|
`trackchanges starting up, listening on ${host}:${port}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ module.exports = DiffManager = {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, doc_id, version },
|
{ project_id, doc_id, version },
|
||||||
'getting document before version'
|
'getting document before version'
|
||||||
)
|
)
|
||||||
|
@ -162,7 +162,7 @@ module.exports = DiffManager = {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.log(
|
logger.debug(
|
||||||
{
|
{
|
||||||
docVersion: version,
|
docVersion: version,
|
||||||
lastUpdateVersion: lastUpdate != null ? lastUpdate.v : undefined,
|
lastUpdateVersion: lastUpdate != null ? lastUpdate.v : undefined,
|
||||||
|
|
|
@ -5,7 +5,7 @@ const Errors = require('./Errors')
|
||||||
|
|
||||||
function peekDocument(projectId, docId, callback) {
|
function peekDocument(projectId, docId, callback) {
|
||||||
const url = `${Settings.apis.docstore.url}/project/${projectId}/doc/${docId}/peek`
|
const url = `${Settings.apis.docstore.url}/project/${projectId}/doc/${docId}/peek`
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id: projectId, doc_id: docId },
|
{ project_id: projectId, doc_id: docId },
|
||||||
'getting doc from docstore'
|
'getting doc from docstore'
|
||||||
)
|
)
|
||||||
|
@ -19,7 +19,7 @@ function peekDocument(projectId, docId, callback) {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id: projectId, doc_id: docId, version: body.version },
|
{ project_id: projectId, doc_id: docId, version: body.version },
|
||||||
'got doc from docstore'
|
'got doc from docstore'
|
||||||
)
|
)
|
||||||
|
|
|
@ -21,7 +21,7 @@ module.exports = DocumentUpdaterManager = {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.log({ project_id, doc_id }, 'getting doc from document updater')
|
logger.debug({ project_id, doc_id }, 'getting doc from document updater')
|
||||||
return request.get(url, function (error, res, body) {
|
return request.get(url, function (error, res, body) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
|
@ -33,7 +33,7 @@ module.exports = DocumentUpdaterManager = {
|
||||||
error = error1
|
error = error1
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, doc_id, version: body.version },
|
{ project_id, doc_id, version: body.version },
|
||||||
'got doc from document updater'
|
'got doc from document updater'
|
||||||
)
|
)
|
||||||
|
@ -66,7 +66,7 @@ module.exports = DocumentUpdaterManager = {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
const url = `${Settings.apis.documentupdater.url}/project/${project_id}/doc/${doc_id}`
|
const url = `${Settings.apis.documentupdater.url}/project/${project_id}/doc/${doc_id}`
|
||||||
logger.log({ project_id, doc_id }, 'setting doc in document updater')
|
logger.debug({ project_id, doc_id }, 'setting doc in document updater')
|
||||||
return request.post(
|
return request.post(
|
||||||
{
|
{
|
||||||
url,
|
url,
|
||||||
|
|
|
@ -21,7 +21,7 @@ module.exports = {
|
||||||
check(callback) {
|
check(callback) {
|
||||||
const project_id = ObjectId(settings.trackchanges.healthCheck.project_id)
|
const project_id = ObjectId(settings.trackchanges.healthCheck.project_id)
|
||||||
const url = `http://localhost:${port}/project/${project_id}`
|
const url = `http://localhost:${port}/project/${project_id}`
|
||||||
logger.log({ project_id }, 'running health check')
|
logger.debug({ project_id }, 'running health check')
|
||||||
const jobs = [
|
const jobs = [
|
||||||
cb =>
|
cb =>
|
||||||
request.get(
|
request.get(
|
||||||
|
|
|
@ -30,7 +30,7 @@ module.exports = HttpController = {
|
||||||
}
|
}
|
||||||
const { doc_id } = req.params
|
const { doc_id } = req.params
|
||||||
const { project_id } = req.params
|
const { project_id } = req.params
|
||||||
logger.log({ project_id, doc_id }, 'compressing doc history')
|
logger.debug({ project_id, doc_id }, 'compressing doc history')
|
||||||
return UpdatesManager.processUncompressedUpdatesWithLock(
|
return UpdatesManager.processUncompressedUpdatesWithLock(
|
||||||
project_id,
|
project_id,
|
||||||
doc_id,
|
doc_id,
|
||||||
|
@ -48,7 +48,7 @@ module.exports = HttpController = {
|
||||||
next = function () {}
|
next = function () {}
|
||||||
}
|
}
|
||||||
const { project_id } = req.params
|
const { project_id } = req.params
|
||||||
logger.log({ project_id }, 'compressing project history')
|
logger.debug({ project_id }, 'compressing project history')
|
||||||
return UpdatesManager.processUncompressedUpdatesForProject(
|
return UpdatesManager.processUncompressedUpdatesForProject(
|
||||||
project_id,
|
project_id,
|
||||||
function (error) {
|
function (error) {
|
||||||
|
@ -66,7 +66,7 @@ module.exports = HttpController = {
|
||||||
next = function () {}
|
next = function () {}
|
||||||
}
|
}
|
||||||
const limit = req.query.limit != null ? parseInt(req.query.limit, 10) : -1
|
const limit = req.query.limit != null ? parseInt(req.query.limit, 10) : -1
|
||||||
logger.log({ limit }, 'flushing all projects')
|
logger.debug({ limit }, 'flushing all projects')
|
||||||
return UpdatesManager.flushAll(limit, function (error, result) {
|
return UpdatesManager.flushAll(limit, function (error, result) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return next(error)
|
return next(error)
|
||||||
|
@ -78,7 +78,7 @@ module.exports = HttpController = {
|
||||||
.status(200)
|
.status(200)
|
||||||
.send(`${status}\nwould flush:\n${all.join('\n')}\n`)
|
.send(`${status}\nwould flush:\n${all.join('\n')}\n`)
|
||||||
} else if (failed.length > 0) {
|
} else if (failed.length > 0) {
|
||||||
logger.log({ failed, succeeded }, 'error flushing projects')
|
logger.debug({ failed, succeeded }, 'error flushing projects')
|
||||||
return res
|
return res
|
||||||
.status(500)
|
.status(500)
|
||||||
.send(`${status}\nfailed to flush:\n${failed.join('\n')}\n`)
|
.send(`${status}\nfailed to flush:\n${failed.join('\n')}\n`)
|
||||||
|
@ -96,13 +96,13 @@ module.exports = HttpController = {
|
||||||
if (next == null) {
|
if (next == null) {
|
||||||
next = function () {}
|
next = function () {}
|
||||||
}
|
}
|
||||||
logger.log('checking dangling updates')
|
logger.debug('checking dangling updates')
|
||||||
return UpdatesManager.getDanglingUpdates(function (error, result) {
|
return UpdatesManager.getDanglingUpdates(function (error, result) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return next(error)
|
return next(error)
|
||||||
}
|
}
|
||||||
if (result.length > 0) {
|
if (result.length > 0) {
|
||||||
logger.log({ dangling: result }, 'found dangling updates')
|
logger.debug({ dangling: result }, 'found dangling updates')
|
||||||
return res.status(500).send(`dangling updates:\n${result.join('\n')}\n`)
|
return res.status(500).send(`dangling updates:\n${result.join('\n')}\n`)
|
||||||
} else {
|
} else {
|
||||||
return res.status(200).send('no dangling updates found\n')
|
return res.status(200).send('no dangling updates found\n')
|
||||||
|
@ -116,7 +116,7 @@ module.exports = HttpController = {
|
||||||
}
|
}
|
||||||
const { doc_id } = req.params
|
const { doc_id } = req.params
|
||||||
const { project_id } = req.params
|
const { project_id } = req.params
|
||||||
logger.log({ project_id, doc_id }, 'checking doc history')
|
logger.debug({ project_id, doc_id }, 'checking doc history')
|
||||||
return DiffManager.getDocumentBeforeVersion(
|
return DiffManager.getDocumentBeforeVersion(
|
||||||
project_id,
|
project_id,
|
||||||
doc_id,
|
doc_id,
|
||||||
|
@ -161,7 +161,7 @@ module.exports = HttpController = {
|
||||||
to = null
|
to = null
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.log({ project_id, doc_id, from, to }, 'getting diff')
|
logger.debug({ project_id, doc_id, from, to }, 'getting diff')
|
||||||
return DiffManager.getDiff(
|
return DiffManager.getDiff(
|
||||||
project_id,
|
project_id,
|
||||||
doc_id,
|
doc_id,
|
||||||
|
@ -207,7 +207,7 @@ module.exports = HttpController = {
|
||||||
|
|
||||||
zipProject(req, res, next) {
|
zipProject(req, res, next) {
|
||||||
const { project_id: projectId } = req.params
|
const { project_id: projectId } = req.params
|
||||||
logger.log({ projectId }, 'exporting project history as zip file')
|
logger.debug({ projectId }, 'exporting project history as zip file')
|
||||||
ZipManager.makeTempDirectory((err, tmpdir) => {
|
ZipManager.makeTempDirectory((err, tmpdir) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err)
|
return next(err)
|
||||||
|
@ -234,7 +234,7 @@ module.exports = HttpController = {
|
||||||
// - multiple updates form a pack
|
// - multiple updates form a pack
|
||||||
// Flush updates per pack onto the wire.
|
// Flush updates per pack onto the wire.
|
||||||
const { project_id } = req.params
|
const { project_id } = req.params
|
||||||
logger.log({ project_id }, 'exporting project history')
|
logger.debug({ project_id }, 'exporting project history')
|
||||||
UpdatesManager.exportProject(
|
UpdatesManager.exportProject(
|
||||||
project_id,
|
project_id,
|
||||||
function (err, { updates, userIds }, confirmWrite) {
|
function (err, { updates, userIds }, confirmWrite) {
|
||||||
|
@ -317,7 +317,7 @@ module.exports = HttpController = {
|
||||||
}
|
}
|
||||||
const { project_id } = req.params
|
const { project_id } = req.params
|
||||||
const { doc_id } = req.params
|
const { doc_id } = req.params
|
||||||
logger.log({ project_id, doc_id }, 'pushing all finalised changes to s3')
|
logger.debug({ project_id, doc_id }, 'pushing all finalised changes to s3')
|
||||||
return PackManager.pushOldPacks(project_id, doc_id, function (error) {
|
return PackManager.pushOldPacks(project_id, doc_id, function (error) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return next(error)
|
return next(error)
|
||||||
|
@ -332,7 +332,7 @@ module.exports = HttpController = {
|
||||||
}
|
}
|
||||||
const { project_id } = req.params
|
const { project_id } = req.params
|
||||||
const { doc_id } = req.params
|
const { doc_id } = req.params
|
||||||
logger.log({ project_id, doc_id }, 'pulling all packs from s3')
|
logger.debug({ project_id, doc_id }, 'pulling all packs from s3')
|
||||||
return PackManager.pullOldPacks(project_id, doc_id, function (error) {
|
return PackManager.pullOldPacks(project_id, doc_id, function (error) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return next(error)
|
return next(error)
|
||||||
|
|
|
@ -64,7 +64,7 @@ module.exports = MongoAWS = {
|
||||||
return callback(new Error('invalid pack id'))
|
return callback(new Error('invalid pack id'))
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.log({ project_id, doc_id, pack_id }, 'uploading data to s3')
|
logger.debug({ project_id, doc_id, pack_id }, 'uploading data to s3')
|
||||||
|
|
||||||
const upload = createStream(S3S.WriteStream, project_id, doc_id, pack_id)
|
const upload = createStream(S3S.WriteStream, project_id, doc_id, pack_id)
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ module.exports = MongoAWS = {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
return zlib.gzip(uncompressedData, function (err, buf) {
|
return zlib.gzip(uncompressedData, function (err, buf) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{
|
{
|
||||||
project_id,
|
project_id,
|
||||||
doc_id,
|
doc_id,
|
||||||
|
@ -101,7 +101,10 @@ module.exports = MongoAWS = {
|
||||||
upload.on('error', err => callback(err))
|
upload.on('error', err => callback(err))
|
||||||
upload.on('finish', function () {
|
upload.on('finish', function () {
|
||||||
Metrics.inc('archive-pack')
|
Metrics.inc('archive-pack')
|
||||||
logger.log({ project_id, doc_id, pack_id }, 'upload to s3 completed')
|
logger.debug(
|
||||||
|
{ project_id, doc_id, pack_id },
|
||||||
|
'upload to s3 completed'
|
||||||
|
)
|
||||||
return callback(null)
|
return callback(null)
|
||||||
})
|
})
|
||||||
upload.write(buf)
|
upload.write(buf)
|
||||||
|
@ -129,7 +132,7 @@ module.exports = MongoAWS = {
|
||||||
return callback(new Error('invalid pack id'))
|
return callback(new Error('invalid pack id'))
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.log({ project_id, doc_id, pack_id }, 'downloading data from s3')
|
logger.debug({ project_id, doc_id, pack_id }, 'downloading data from s3')
|
||||||
|
|
||||||
const download = createStream(S3S.ReadStream, project_id, doc_id, pack_id)
|
const download = createStream(S3S.ReadStream, project_id, doc_id, pack_id)
|
||||||
|
|
||||||
|
@ -140,7 +143,7 @@ module.exports = MongoAWS = {
|
||||||
const gunzip = zlib.createGunzip()
|
const gunzip = zlib.createGunzip()
|
||||||
gunzip.setEncoding('utf8')
|
gunzip.setEncoding('utf8')
|
||||||
gunzip.on('error', function (err) {
|
gunzip.on('error', function (err) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, doc_id, pack_id, err },
|
{ project_id, doc_id, pack_id, err },
|
||||||
'error uncompressing gzip stream'
|
'error uncompressing gzip stream'
|
||||||
)
|
)
|
||||||
|
@ -152,7 +155,10 @@ module.exports = MongoAWS = {
|
||||||
outputStream.on('error', err => callback(err))
|
outputStream.on('error', err => callback(err))
|
||||||
outputStream.on('end', function () {
|
outputStream.on('end', function () {
|
||||||
let object
|
let object
|
||||||
logger.log({ project_id, doc_id, pack_id }, 'download from s3 completed')
|
logger.debug(
|
||||||
|
{ project_id, doc_id, pack_id },
|
||||||
|
'download from s3 completed'
|
||||||
|
)
|
||||||
try {
|
try {
|
||||||
object = JSON.parse(parts.join(''))
|
object = JSON.parse(parts.join(''))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -186,7 +192,10 @@ module.exports = MongoAWS = {
|
||||||
Metrics.inc('unarchive-pack')
|
Metrics.inc('unarchive-pack')
|
||||||
// allow the object to expire, we can always retrieve it again
|
// allow the object to expire, we can always retrieve it again
|
||||||
object.expiresAt = new Date(Date.now() + 7 * DAYS)
|
object.expiresAt = new Date(Date.now() + 7 * DAYS)
|
||||||
logger.log({ project_id, doc_id, pack_id }, 'inserting object from s3')
|
logger.debug(
|
||||||
|
{ project_id, doc_id, pack_id },
|
||||||
|
'inserting object from s3'
|
||||||
|
)
|
||||||
return db.docHistory.insertOne(object, (err, confirmation) => {
|
return db.docHistory.insertOne(object, (err, confirmation) => {
|
||||||
if (err) return callback(err)
|
if (err) return callback(err)
|
||||||
object._id = confirmation.insertedId
|
object._id = confirmation.insertedId
|
||||||
|
|
|
@ -217,7 +217,7 @@ module.exports = PackManager = {
|
||||||
newPack.expiresAt = new Date(Date.now() + 7 * DAYS)
|
newPack.expiresAt = new Date(Date.now() + 7 * DAYS)
|
||||||
newPack.last_checked = new Date(Date.now() + 30 * DAYS) // never check temporary packs
|
newPack.last_checked = new Date(Date.now() + 30 * DAYS) // never check temporary packs
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, doc_id, newUpdates },
|
{ project_id, doc_id, newUpdates },
|
||||||
'inserting updates into new pack'
|
'inserting updates into new pack'
|
||||||
)
|
)
|
||||||
|
@ -271,7 +271,7 @@ module.exports = PackManager = {
|
||||||
if (lastUpdate.expiresAt && temporary) {
|
if (lastUpdate.expiresAt && temporary) {
|
||||||
update.$set.expiresAt = new Date(Date.now() + 7 * DAYS)
|
update.$set.expiresAt = new Date(Date.now() + 7 * DAYS)
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, doc_id, lastUpdate, newUpdates },
|
{ project_id, doc_id, lastUpdate, newUpdates },
|
||||||
'appending updates to existing pack'
|
'appending updates to existing pack'
|
||||||
)
|
)
|
||||||
|
@ -402,7 +402,7 @@ module.exports = PackManager = {
|
||||||
pack._id.toString()
|
pack._id.toString()
|
||||||
)
|
)
|
||||||
const packIdsToFetch = _.difference(allPackIds, loadedPackIds)
|
const packIdsToFetch = _.difference(allPackIds, loadedPackIds)
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, doc_id, loadedPackIds, allPackIds, packIdsToFetch },
|
{ project_id, doc_id, loadedPackIds, allPackIds, packIdsToFetch },
|
||||||
'analysed packs'
|
'analysed packs'
|
||||||
)
|
)
|
||||||
|
@ -418,7 +418,7 @@ module.exports = PackManager = {
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
return callback(err)
|
return callback(err)
|
||||||
}
|
}
|
||||||
logger.log({ project_id, doc_id }, 'done unarchiving')
|
logger.debug({ project_id, doc_id }, 'done unarchiving')
|
||||||
return callback()
|
return callback()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -663,7 +663,7 @@ module.exports = PackManager = {
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
return callback(err)
|
return callback(err)
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, doc_id, newPacks },
|
{ project_id, doc_id, newPacks },
|
||||||
'added new packs to index'
|
'added new packs to index'
|
||||||
)
|
)
|
||||||
|
@ -769,7 +769,7 @@ module.exports = PackManager = {
|
||||||
return result1
|
return result1
|
||||||
})()
|
})()
|
||||||
if (newPacks.length) {
|
if (newPacks.length) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, doc_id, n: newPacks.length },
|
{ project_id, doc_id, n: newPacks.length },
|
||||||
'found new packs'
|
'found new packs'
|
||||||
)
|
)
|
||||||
|
@ -959,7 +959,7 @@ module.exports = PackManager = {
|
||||||
return callback(err)
|
return callback(err)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
logger.log({ project_id, doc_id }, 'processing old packs')
|
logger.debug({ project_id, doc_id }, 'processing old packs')
|
||||||
return db.docHistory.findOne({ _id: pack_id }, function (err, pack) {
|
return db.docHistory.findOne({ _id: pack_id }, function (err, pack) {
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
return markAsChecked(err)
|
return markAsChecked(err)
|
||||||
|
@ -998,7 +998,7 @@ module.exports = PackManager = {
|
||||||
? unarchivedPacks.length
|
? unarchivedPacks.length
|
||||||
: undefined)
|
: undefined)
|
||||||
) {
|
) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, doc_id },
|
{ project_id, doc_id },
|
||||||
'no packs need archiving'
|
'no packs need archiving'
|
||||||
)
|
)
|
||||||
|
@ -1012,7 +1012,7 @@ module.exports = PackManager = {
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
return markAsChecked(err)
|
return markAsChecked(err)
|
||||||
}
|
}
|
||||||
logger.log({ project_id, doc_id }, 'done processing')
|
logger.debug({ project_id, doc_id }, 'done processing')
|
||||||
return markAsChecked()
|
return markAsChecked()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -1031,13 +1031,16 @@ module.exports = PackManager = {
|
||||||
const age = (Date.now() - pack.meta.end_ts) / DAYS
|
const age = (Date.now() - pack.meta.end_ts) / DAYS
|
||||||
if (age < 30) {
|
if (age < 30) {
|
||||||
// always keep if less than 1 month old
|
// always keep if less than 1 month old
|
||||||
logger.log({ project_id, doc_id, pack_id, age }, 'less than 30 days old')
|
logger.debug(
|
||||||
|
{ project_id, doc_id, pack_id, age },
|
||||||
|
'less than 30 days old'
|
||||||
|
)
|
||||||
return callback()
|
return callback()
|
||||||
}
|
}
|
||||||
// compute an archiving threshold which decreases for each month of age
|
// compute an archiving threshold which decreases for each month of age
|
||||||
const archive_threshold = 30 / age
|
const archive_threshold = 30 / age
|
||||||
if (sz > archive_threshold || n > archive_threshold || age > 90) {
|
if (sz > archive_threshold || n > archive_threshold || age > 90) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, doc_id, pack_id, age, archive_threshold, sz, n },
|
{ project_id, doc_id, pack_id, age, archive_threshold, sz, n },
|
||||||
'meets archive threshold'
|
'meets archive threshold'
|
||||||
)
|
)
|
||||||
|
@ -1048,7 +1051,7 @@ module.exports = PackManager = {
|
||||||
callback
|
callback
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, doc_id, pack_id, age, archive_threshold, sz, n },
|
{ project_id, doc_id, pack_id, age, archive_threshold, sz, n },
|
||||||
'does not meet archive threshold'
|
'does not meet archive threshold'
|
||||||
)
|
)
|
||||||
|
@ -1071,7 +1074,7 @@ module.exports = PackManager = {
|
||||||
},
|
},
|
||||||
|
|
||||||
_markPackAsFinalised(project_id, doc_id, pack_id, callback) {
|
_markPackAsFinalised(project_id, doc_id, pack_id, callback) {
|
||||||
logger.log({ project_id, doc_id, pack_id }, 'marking pack as finalised')
|
logger.debug({ project_id, doc_id, pack_id }, 'marking pack as finalised')
|
||||||
return db.docHistory.updateOne(
|
return db.docHistory.updateOne(
|
||||||
{ _id: pack_id },
|
{ _id: pack_id },
|
||||||
{ $set: { finalised: true } },
|
{ $set: { finalised: true } },
|
||||||
|
@ -1080,7 +1083,7 @@ module.exports = PackManager = {
|
||||||
},
|
},
|
||||||
|
|
||||||
updateIndexIfNeeded(project_id, doc_id, callback) {
|
updateIndexIfNeeded(project_id, doc_id, callback) {
|
||||||
logger.log({ project_id, doc_id }, 'archiving old packs')
|
logger.debug({ project_id, doc_id }, 'archiving old packs')
|
||||||
return PackManager.getIndexWithKeys(doc_id, function (err, index) {
|
return PackManager.getIndexWithKeys(doc_id, function (err, index) {
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
return callback(err)
|
return callback(err)
|
||||||
|
@ -1094,7 +1097,7 @@ module.exports = PackManager = {
|
||||||
},
|
},
|
||||||
|
|
||||||
markPackAsChecked(project_id, doc_id, pack_id, callback) {
|
markPackAsChecked(project_id, doc_id, pack_id, callback) {
|
||||||
logger.log({ project_id, doc_id, pack_id }, 'marking pack as checked')
|
logger.debug({ project_id, doc_id, pack_id }, 'marking pack as checked')
|
||||||
return db.docHistory.updateOne(
|
return db.docHistory.updateOne(
|
||||||
{ _id: pack_id },
|
{ _id: pack_id },
|
||||||
{ $currentDate: { last_checked: true } },
|
{ $currentDate: { last_checked: true } },
|
||||||
|
@ -1119,7 +1122,7 @@ module.exports = PackManager = {
|
||||||
return result
|
return result
|
||||||
})()
|
})()
|
||||||
if (unArchivedPacks.length) {
|
if (unArchivedPacks.length) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, doc_id, n: unArchivedPacks.length },
|
{ project_id, doc_id, n: unArchivedPacks.length },
|
||||||
'find unarchived packs'
|
'find unarchived packs'
|
||||||
)
|
)
|
||||||
|
@ -1131,7 +1134,7 @@ module.exports = PackManager = {
|
||||||
// Archive locking flags
|
// Archive locking flags
|
||||||
|
|
||||||
checkArchiveNotInProgress(project_id, doc_id, pack_id, callback) {
|
checkArchiveNotInProgress(project_id, doc_id, pack_id, callback) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, doc_id, pack_id },
|
{ project_id, doc_id, pack_id },
|
||||||
'checking if archive in progress'
|
'checking if archive in progress'
|
||||||
)
|
)
|
||||||
|
@ -1157,7 +1160,7 @@ module.exports = PackManager = {
|
||||||
},
|
},
|
||||||
|
|
||||||
markPackAsArchiveInProgress(project_id, doc_id, pack_id, callback) {
|
markPackAsArchiveInProgress(project_id, doc_id, pack_id, callback) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, doc_id },
|
{ project_id, doc_id },
|
||||||
'marking pack as archive in progress status'
|
'marking pack as archive in progress status'
|
||||||
)
|
)
|
||||||
|
@ -1175,7 +1178,7 @@ module.exports = PackManager = {
|
||||||
if (!result.value) {
|
if (!result.value) {
|
||||||
return callback(new Error('archive is already in progress'))
|
return callback(new Error('archive is already in progress'))
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, doc_id, pack_id },
|
{ project_id, doc_id, pack_id },
|
||||||
'marked as archive in progress'
|
'marked as archive in progress'
|
||||||
)
|
)
|
||||||
|
@ -1185,7 +1188,7 @@ module.exports = PackManager = {
|
||||||
},
|
},
|
||||||
|
|
||||||
clearPackAsArchiveInProgress(project_id, doc_id, pack_id, callback) {
|
clearPackAsArchiveInProgress(project_id, doc_id, pack_id, callback) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, doc_id, pack_id },
|
{ project_id, doc_id, pack_id },
|
||||||
'clearing as archive in progress'
|
'clearing as archive in progress'
|
||||||
)
|
)
|
||||||
|
@ -1200,7 +1203,7 @@ module.exports = PackManager = {
|
||||||
},
|
},
|
||||||
|
|
||||||
markPackAsArchived(project_id, doc_id, pack_id, callback) {
|
markPackAsArchived(project_id, doc_id, pack_id, callback) {
|
||||||
logger.log({ project_id, doc_id, pack_id }, 'marking pack as archived')
|
logger.debug({ project_id, doc_id, pack_id }, 'marking pack as archived')
|
||||||
return db.docHistoryIndex.findOneAndUpdate(
|
return db.docHistoryIndex.findOneAndUpdate(
|
||||||
{
|
{
|
||||||
_id: ObjectId(doc_id.toString()),
|
_id: ObjectId(doc_id.toString()),
|
||||||
|
@ -1215,7 +1218,7 @@ module.exports = PackManager = {
|
||||||
if (!result.value) {
|
if (!result.value) {
|
||||||
return callback(new Error('archive is not marked as progress'))
|
return callback(new Error('archive is not marked as progress'))
|
||||||
}
|
}
|
||||||
logger.log({ project_id, doc_id, pack_id }, 'marked as archived')
|
logger.debug({ project_id, doc_id, pack_id }, 'marked as archived')
|
||||||
return callback()
|
return callback()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -1229,7 +1232,7 @@ module.exports = PackManager = {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err)
|
return callback(err)
|
||||||
}
|
}
|
||||||
logger.log({ project_id, doc_id, pack_id }, 'set expiry on pack')
|
logger.debug({ project_id, doc_id, pack_id }, 'set expiry on pack')
|
||||||
return callback()
|
return callback()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -64,7 +64,7 @@ if (!source.match(/^[0-9]+$/)) {
|
||||||
|
|
||||||
let shutDownRequested = false
|
let shutDownRequested = false
|
||||||
const shutDownTimer = setTimeout(function () {
|
const shutDownTimer = setTimeout(function () {
|
||||||
logger.log('pack timed out, requesting shutdown')
|
logger.debug('pack timed out, requesting shutdown')
|
||||||
// start the shutdown on the next pack
|
// start the shutdown on the next pack
|
||||||
shutDownRequested = true
|
shutDownRequested = true
|
||||||
// do a hard shutdown after a further 5 minutes
|
// do a hard shutdown after a further 5 minutes
|
||||||
|
@ -75,20 +75,20 @@ const shutDownTimer = setTimeout(function () {
|
||||||
return hardTimeout.unref()
|
return hardTimeout.unref()
|
||||||
}, TIMEOUT)
|
}, TIMEOUT)
|
||||||
|
|
||||||
logger.log(
|
logger.debug(
|
||||||
`checking for updates, limit=${LIMIT}, delay=${DOCUMENT_PACK_DELAY}, timeout=${TIMEOUT}`
|
`checking for updates, limit=${LIMIT}, delay=${DOCUMENT_PACK_DELAY}, timeout=${TIMEOUT}`
|
||||||
)
|
)
|
||||||
|
|
||||||
const finish = function () {
|
const finish = function () {
|
||||||
if (shutDownTimer != null) {
|
if (shutDownTimer != null) {
|
||||||
logger.log('cancelling timeout')
|
logger.debug('cancelling timeout')
|
||||||
clearTimeout(shutDownTimer)
|
clearTimeout(shutDownTimer)
|
||||||
}
|
}
|
||||||
logger.log('closing db')
|
logger.debug('closing db')
|
||||||
callbackify(closeDb)(function () {
|
callbackify(closeDb)(function () {
|
||||||
logger.log('closing LockManager Redis Connection')
|
logger.debug('closing LockManager Redis Connection')
|
||||||
return LockManager.close(function () {
|
return LockManager.close(function () {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ processedCount: COUNT, allCount: TOTAL },
|
{ processedCount: COUNT, allCount: TOTAL },
|
||||||
'ready to exit from pack archive worker'
|
'ready to exit from pack archive worker'
|
||||||
)
|
)
|
||||||
|
@ -101,7 +101,7 @@ const finish = function () {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
process.on('exit', code => logger.log({ code }, 'pack archive worker exited'))
|
process.on('exit', code => logger.debug({ code }, 'pack archive worker exited'))
|
||||||
|
|
||||||
const processUpdates = pending =>
|
const processUpdates = pending =>
|
||||||
async.eachSeries(
|
async.eachSeries(
|
||||||
|
@ -110,9 +110,9 @@ const processUpdates = pending =>
|
||||||
let _id
|
let _id
|
||||||
;({ _id, project_id, doc_id } = result)
|
;({ _id, project_id, doc_id } = result)
|
||||||
COUNT++
|
COUNT++
|
||||||
logger.log({ project_id, doc_id }, `processing ${COUNT}/${TOTAL}`)
|
logger.debug({ project_id, doc_id }, `processing ${COUNT}/${TOTAL}`)
|
||||||
if (project_id == null || doc_id == null) {
|
if (project_id == null || doc_id == null) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, doc_id },
|
{ project_id, doc_id },
|
||||||
'skipping pack, missing project/doc id'
|
'skipping pack, missing project/doc id'
|
||||||
)
|
)
|
||||||
|
@ -164,7 +164,7 @@ const ObjectIdFromDate = function (date) {
|
||||||
waitForDb()
|
waitForDb()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (pending != null) {
|
if (pending != null) {
|
||||||
logger.log(`got ${pending.length} entries from ${source}`)
|
logger.debug(`got ${pending.length} entries from ${source}`)
|
||||||
processUpdates(pending)
|
processUpdates(pending)
|
||||||
} else {
|
} else {
|
||||||
processFromOneWeekAgo()
|
processFromOneWeekAgo()
|
||||||
|
@ -194,13 +194,13 @@ function processFromOneWeekAgo() {
|
||||||
.limit(LIMIT)
|
.limit(LIMIT)
|
||||||
.toArray(function (err, results) {
|
.toArray(function (err, results) {
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
logger.log({ err }, 'error checking for updates')
|
logger.debug({ err }, 'error checking for updates')
|
||||||
finish()
|
finish()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
pending = _.uniq(results, false, result => result.doc_id.toString())
|
pending = _.uniq(results, false, result => result.doc_id.toString())
|
||||||
TOTAL = pending.length
|
TOTAL = pending.length
|
||||||
logger.log(`found ${TOTAL} documents to archive`)
|
logger.debug(`found ${TOTAL} documents to archive`)
|
||||||
return processUpdates(pending)
|
return processUpdates(pending)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ module.exports = RestoreManager = {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
logger.log({ project_id, doc_id, version, user_id }, 'restoring document')
|
logger.debug({ project_id, doc_id, version, user_id }, 'restoring document')
|
||||||
return DiffManager.getDocumentBeforeVersion(
|
return DiffManager.getDocumentBeforeVersion(
|
||||||
project_id,
|
project_id,
|
||||||
doc_id,
|
doc_id,
|
||||||
|
|
|
@ -36,7 +36,7 @@ module.exports = UpdateTrimmer = {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
logger.log({ project_id, details }, 'got details')
|
logger.debug({ project_id, details }, 'got details')
|
||||||
if (
|
if (
|
||||||
__guard__(
|
__guard__(
|
||||||
details != null ? details.features : undefined,
|
details != null ? details.features : undefined,
|
||||||
|
|
|
@ -182,7 +182,7 @@ module.exports = UpdatesManager = {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{
|
{
|
||||||
project_id,
|
project_id,
|
||||||
doc_id,
|
doc_id,
|
||||||
|
@ -257,7 +257,7 @@ module.exports = UpdatesManager = {
|
||||||
)
|
)
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, doc_id, rawUpdates },
|
{ project_id, doc_id, rawUpdates },
|
||||||
'retrieved raw updates from redis'
|
'retrieved raw updates from redis'
|
||||||
)
|
)
|
||||||
|
@ -270,7 +270,7 @@ module.exports = UpdatesManager = {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, doc_id },
|
{ project_id, doc_id },
|
||||||
'compressed and saved doc updates'
|
'compressed and saved doc updates'
|
||||||
)
|
)
|
||||||
|
@ -285,7 +285,7 @@ module.exports = UpdatesManager = {
|
||||||
}
|
}
|
||||||
if (length === UpdatesManager.REDIS_READ_BATCH_SIZE) {
|
if (length === UpdatesManager.REDIS_READ_BATCH_SIZE) {
|
||||||
// There might be more updates
|
// There might be more updates
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, doc_id },
|
{ project_id, doc_id },
|
||||||
'continuing processing updates'
|
'continuing processing updates'
|
||||||
)
|
)
|
||||||
|
@ -300,7 +300,7 @@ module.exports = UpdatesManager = {
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, doc_id },
|
{ project_id, doc_id },
|
||||||
'all raw updates processed'
|
'all raw updates processed'
|
||||||
)
|
)
|
||||||
|
@ -416,7 +416,7 @@ module.exports = UpdatesManager = {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{
|
{
|
||||||
count: project_ids != null ? project_ids.length : undefined,
|
count: project_ids != null ? project_ids.length : undefined,
|
||||||
project_ids,
|
project_ids,
|
||||||
|
@ -497,7 +497,7 @@ module.exports = UpdatesManager = {
|
||||||
return task(function (error, project_doc_ids) {
|
return task(function (error, project_doc_ids) {
|
||||||
if (error) return callback(error)
|
if (error) return callback(error)
|
||||||
const dangling_doc_ids = _.difference(all_doc_ids, project_doc_ids)
|
const dangling_doc_ids = _.difference(all_doc_ids, project_doc_ids)
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ all_doc_ids, all_project_ids, project_doc_ids, dangling_doc_ids },
|
{ all_doc_ids, all_project_ids, project_doc_ids, dangling_doc_ids },
|
||||||
'checking for dangling doc ids'
|
'checking for dangling doc ids'
|
||||||
)
|
)
|
||||||
|
|
|
@ -43,7 +43,7 @@ module.exports = WebApiManager = {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
if (res.statusCode === 404) {
|
if (res.statusCode === 404) {
|
||||||
logger.log({ url }, 'got 404 from web api')
|
logger.debug({ url }, 'got 404 from web api')
|
||||||
return callback(null, null)
|
return callback(null, null)
|
||||||
}
|
}
|
||||||
if (res.statusCode >= 200 && res.statusCode < 300) {
|
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||||
|
@ -63,7 +63,7 @@ module.exports = WebApiManager = {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
const url = `/user/${user_id}/personal_info`
|
const url = `/user/${user_id}/personal_info`
|
||||||
logger.log({ user_id }, 'getting user info from web')
|
logger.debug({ user_id }, 'getting user info from web')
|
||||||
return WebApiManager.sendRequest(url, function (error, body) {
|
return WebApiManager.sendRequest(url, function (error, body) {
|
||||||
let user
|
let user
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
|
@ -95,7 +95,7 @@ module.exports = WebApiManager = {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
const url = `/project/${project_id}/details`
|
const url = `/project/${project_id}/details`
|
||||||
logger.log({ project_id }, 'getting project details from web')
|
logger.debug({ project_id }, 'getting project details from web')
|
||||||
return WebApiManager.sendRequest(url, function (error, body) {
|
return WebApiManager.sendRequest(url, function (error, body) {
|
||||||
let project
|
let project
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ async function getLatestContent(projectId, docId, lastUpdateVersion) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function rewindDoc(projectId, docId, zipfile) {
|
async function rewindDoc(projectId, docId, zipfile) {
|
||||||
logger.log({ projectId, docId }, 'rewinding document')
|
logger.debug({ projectId, docId }, 'rewinding document')
|
||||||
|
|
||||||
// Prepare to rewind content
|
// Prepare to rewind content
|
||||||
|
|
||||||
|
|
|
@ -60,8 +60,10 @@ if (!module.parent) {
|
||||||
Promise.all([mongodb.waitForDb(), mongoose.connectionPromise])
|
Promise.all([mongodb.waitForDb(), mongoose.connectionPromise])
|
||||||
.then(() => {
|
.then(() => {
|
||||||
Server.server.listen(port, host, function () {
|
Server.server.listen(port, host, function () {
|
||||||
logger.info(`web starting up, listening on ${host}:${port}`)
|
logger.debug(`web starting up, listening on ${host}:${port}`)
|
||||||
logger.info(`${require('http').globalAgent.maxSockets} sockets enabled`)
|
logger.debug(
|
||||||
|
`${require('http').globalAgent.maxSockets} sockets enabled`
|
||||||
|
)
|
||||||
// wait until the process is ready before monitoring the event loop
|
// wait until the process is ready before monitoring the event loop
|
||||||
metrics.event_loop.monitor(logger)
|
metrics.event_loop.monitor(logger)
|
||||||
})
|
})
|
||||||
|
|
|
@ -65,7 +65,7 @@ function recordEventForSession(session, event, segmentation) {
|
||||||
if (_isAnalyticsDisabled() || _isSmokeTestUser(userId)) {
|
if (_isAnalyticsDisabled() || _isSmokeTestUser(userId)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
logger.info({
|
logger.debug({
|
||||||
analyticsId,
|
analyticsId,
|
||||||
userId,
|
userId,
|
||||||
event,
|
event,
|
||||||
|
|
|
@ -190,7 +190,7 @@ const AuthenticationController = {
|
||||||
return done(err)
|
return done(err)
|
||||||
}
|
}
|
||||||
if (!isAllowed) {
|
if (!isAllowed) {
|
||||||
logger.log({ email }, 'too many login requests')
|
logger.debug({ email }, 'too many login requests')
|
||||||
return done(null, null, {
|
return done(null, null, {
|
||||||
text: req.i18n.translate('to_many_login_requests_2_mins'),
|
text: req.i18n.translate('to_many_login_requests_2_mins'),
|
||||||
type: 'error',
|
type: 'error',
|
||||||
|
@ -222,7 +222,7 @@ const AuthenticationController = {
|
||||||
done(null, user)
|
done(null, user)
|
||||||
} else {
|
} else {
|
||||||
AuthenticationController._recordFailedLogin()
|
AuthenticationController._recordFailedLogin()
|
||||||
logger.log({ email }, 'failed log in')
|
logger.debug({ email }, 'failed log in')
|
||||||
done(null, false, {
|
done(null, false, {
|
||||||
text: req.i18n.translate('email_or_password_wrong_try_again'),
|
text: req.i18n.translate('email_or_password_wrong_try_again'),
|
||||||
type: 'error',
|
type: 'error',
|
||||||
|
@ -372,7 +372,7 @@ const AuthenticationController = {
|
||||||
} else if (SessionManager.isUserLoggedIn(req.session)) {
|
} else if (SessionManager.isUserLoggedIn(req.session)) {
|
||||||
next()
|
next()
|
||||||
} else {
|
} else {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ url: req.url },
|
{ url: req.url },
|
||||||
'user trying to access endpoint not in global whitelist'
|
'user trying to access endpoint not in global whitelist'
|
||||||
)
|
)
|
||||||
|
@ -475,7 +475,7 @@ const AuthenticationController = {
|
||||||
},
|
},
|
||||||
|
|
||||||
_redirectToLoginPage(req, res) {
|
_redirectToLoginPage(req, res) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ url: req.url },
|
{ url: req.url },
|
||||||
'user not logged in so redirecting to login page'
|
'user not logged in so redirecting to login page'
|
||||||
)
|
)
|
||||||
|
@ -486,7 +486,7 @@ const AuthenticationController = {
|
||||||
},
|
},
|
||||||
|
|
||||||
_redirectToReconfirmPage(req, res, user) {
|
_redirectToReconfirmPage(req, res, user) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ url: req.url },
|
{ url: req.url },
|
||||||
'user needs to reconfirm so redirecting to reconfirm page'
|
'user needs to reconfirm so redirecting to reconfirm page'
|
||||||
)
|
)
|
||||||
|
@ -496,7 +496,7 @@ const AuthenticationController = {
|
||||||
},
|
},
|
||||||
|
|
||||||
_redirectToRegisterPage(req, res) {
|
_redirectToRegisterPage(req, res) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ url: req.url },
|
{ url: req.url },
|
||||||
'user not logged in so redirecting to register page'
|
'user not logged in so redirecting to register page'
|
||||||
)
|
)
|
||||||
|
@ -617,7 +617,7 @@ function _loginAsyncHandlers(req, user, anonymousAnalyticsId, isNewUser) {
|
||||||
})
|
})
|
||||||
Analytics.identifyUser(user._id, anonymousAnalyticsId, isNewUser)
|
Analytics.identifyUser(user._id, anonymousAnalyticsId, isNewUser)
|
||||||
|
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ email: user.email, user_id: user._id.toString() },
|
{ email: user.email, user_id: user._id.toString() },
|
||||||
'successful log in'
|
'successful log in'
|
||||||
)
|
)
|
||||||
|
|
|
@ -64,10 +64,10 @@ async function ensureUserCanReadProject(req, res, next) {
|
||||||
token
|
token
|
||||||
)
|
)
|
||||||
if (canRead) {
|
if (canRead) {
|
||||||
logger.log({ userId, projectId }, 'allowing user read access to project')
|
logger.debug({ userId, projectId }, 'allowing user read access to project')
|
||||||
return next()
|
return next()
|
||||||
}
|
}
|
||||||
logger.log({ userId, projectId }, 'denying user read access to project')
|
logger.debug({ userId, projectId }, 'denying user read access to project')
|
||||||
HttpErrorHandler.forbidden(req, res)
|
HttpErrorHandler.forbidden(req, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,13 +114,13 @@ async function ensureUserCanWriteProjectContent(req, res, next) {
|
||||||
token
|
token
|
||||||
)
|
)
|
||||||
if (canWrite) {
|
if (canWrite) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ userId, projectId },
|
{ userId, projectId },
|
||||||
'allowing user write access to project content'
|
'allowing user write access to project content'
|
||||||
)
|
)
|
||||||
return next()
|
return next()
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ userId, projectId },
|
{ userId, projectId },
|
||||||
'denying user write access to project settings'
|
'denying user write access to project settings'
|
||||||
)
|
)
|
||||||
|
@ -137,21 +137,21 @@ async function ensureUserCanAdminProject(req, res, next) {
|
||||||
token
|
token
|
||||||
)
|
)
|
||||||
if (canAdmin) {
|
if (canAdmin) {
|
||||||
logger.log({ userId, projectId }, 'allowing user admin access to project')
|
logger.debug({ userId, projectId }, 'allowing user admin access to project')
|
||||||
return next()
|
return next()
|
||||||
}
|
}
|
||||||
logger.log({ userId, projectId }, 'denying user admin access to project')
|
logger.debug({ userId, projectId }, 'denying user admin access to project')
|
||||||
HttpErrorHandler.forbidden(req, res)
|
HttpErrorHandler.forbidden(req, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function ensureUserIsSiteAdmin(req, res, next) {
|
async function ensureUserIsSiteAdmin(req, res, next) {
|
||||||
const userId = _getUserId(req)
|
const userId = _getUserId(req)
|
||||||
if (await AuthorizationManager.promises.isUserSiteAdmin(userId)) {
|
if (await AuthorizationManager.promises.isUserSiteAdmin(userId)) {
|
||||||
logger.log({ userId }, 'allowing user admin access to site')
|
logger.debug({ userId }, 'allowing user admin access to site')
|
||||||
return next()
|
return next()
|
||||||
}
|
}
|
||||||
if (handleAdminDomainRedirect(req, res)) return
|
if (handleAdminDomainRedirect(req, res)) return
|
||||||
logger.log({ userId }, 'denying user admin access to site')
|
logger.debug({ userId }, 'denying user admin access to site')
|
||||||
_redirectToRestricted(req, res, next)
|
_redirectToRestricted(req, res, next)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ function restricted(req, res, next) {
|
||||||
return res.render('user/restricted', { title: 'restricted' })
|
return res.render('user/restricted', { title: 'restricted' })
|
||||||
}
|
}
|
||||||
const { from } = req.query
|
const { from } = req.query
|
||||||
logger.log({ from }, 'redirecting to login')
|
logger.debug({ from }, 'redirecting to login')
|
||||||
if (from) {
|
if (from) {
|
||||||
AuthenticationController.setRedirectInSession(req, from)
|
AuthenticationController.setRedirectInSession(req, from)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ const SessionManager = require('../Authentication/SessionManager')
|
||||||
const BetaProgramController = {
|
const BetaProgramController = {
|
||||||
optIn(req, res, next) {
|
optIn(req, res, next) {
|
||||||
const userId = SessionManager.getLoggedInUserId(req.session)
|
const userId = SessionManager.getLoggedInUserId(req.session)
|
||||||
logger.log({ userId }, 'user opting in to beta program')
|
logger.debug({ userId }, 'user opting in to beta program')
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
return next(new Error('no user id in session'))
|
return next(new Error('no user id in session'))
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ const BetaProgramController = {
|
||||||
|
|
||||||
optOut(req, res, next) {
|
optOut(req, res, next) {
|
||||||
const userId = SessionManager.getLoggedInUserId(req.session)
|
const userId = SessionManager.getLoggedInUserId(req.session)
|
||||||
logger.log({ userId }, 'user opting out of beta program')
|
logger.debug({ userId }, 'user opting out of beta program')
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
return next(new Error('no user id in session'))
|
return next(new Error('no user id in session'))
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,10 @@ const BetaProgramController = {
|
||||||
|
|
||||||
optInPage(req, res, next) {
|
optInPage(req, res, next) {
|
||||||
const userId = SessionManager.getLoggedInUserId(req.session)
|
const userId = SessionManager.getLoggedInUserId(req.session)
|
||||||
logger.log({ user_id: userId }, 'showing beta participation page for user')
|
logger.debug(
|
||||||
|
{ user_id: userId },
|
||||||
|
'showing beta participation page for user'
|
||||||
|
)
|
||||||
UserGetter.getUser(userId, function (err, user) {
|
UserGetter.getUser(userId, function (err, user) {
|
||||||
if (err) {
|
if (err) {
|
||||||
OError.tag(err, 'error fetching user', {
|
OError.tag(err, 'error fetching user', {
|
||||||
|
|
|
@ -13,7 +13,7 @@ function getBrandVariationById(brandVariationId, callback) {
|
||||||
if (brandVariationId == null || brandVariationId === '') {
|
if (brandVariationId == null || brandVariationId === '') {
|
||||||
return callback(new Error('Branding variation id not provided'))
|
return callback(new Error('Branding variation id not provided'))
|
||||||
}
|
}
|
||||||
logger.log({ brandVariationId }, 'fetching brand variation details from v1')
|
logger.debug({ brandVariationId }, 'fetching brand variation details from v1')
|
||||||
V1Api.request(
|
V1Api.request(
|
||||||
{
|
{
|
||||||
uri: `/api/v2/brand_variations/${brandVariationId}`,
|
uri: `/api/v2/brand_variations/${brandVariationId}`,
|
||||||
|
|
|
@ -39,7 +39,7 @@ async function removeSelfFromProject(req, res, next) {
|
||||||
|
|
||||||
async function getAllMembers(req, res, next) {
|
async function getAllMembers(req, res, next) {
|
||||||
const projectId = req.params.Project_id
|
const projectId = req.params.Project_id
|
||||||
logger.log({ projectId }, 'getting all active members for project')
|
logger.debug({ projectId }, 'getting all active members for project')
|
||||||
let members
|
let members
|
||||||
try {
|
try {
|
||||||
members = await CollaboratorsGetter.promises.getAllInvitedMembers(projectId)
|
members = await CollaboratorsGetter.promises.getAllInvitedMembers(projectId)
|
||||||
|
|
|
@ -110,10 +110,13 @@ async function addUserIdToProject(
|
||||||
}
|
}
|
||||||
if (privilegeLevel === PrivilegeLevels.READ_AND_WRITE) {
|
if (privilegeLevel === PrivilegeLevels.READ_AND_WRITE) {
|
||||||
level = { collaberator_refs: userId }
|
level = { collaberator_refs: userId }
|
||||||
logger.log({ privileges: 'readAndWrite', userId, projectId }, 'adding user')
|
logger.debug(
|
||||||
|
{ privileges: 'readAndWrite', userId, projectId },
|
||||||
|
'adding user'
|
||||||
|
)
|
||||||
} else if (privilegeLevel === PrivilegeLevels.READ_ONLY) {
|
} else if (privilegeLevel === PrivilegeLevels.READ_ONLY) {
|
||||||
level = { readOnly_refs: userId }
|
level = { readOnly_refs: userId }
|
||||||
logger.log({ privileges: 'readOnly', userId, projectId }, 'adding user')
|
logger.debug({ privileges: 'readOnly', userId, projectId }, 'adding user')
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`unknown privilegeLevel: ${privilegeLevel}`)
|
throw new Error(`unknown privilegeLevel: ${privilegeLevel}`)
|
||||||
}
|
}
|
||||||
|
@ -146,7 +149,7 @@ async function transferProjects(fromUserId, toUserId) {
|
||||||
{ _id: 1 }
|
{ _id: 1 }
|
||||||
).exec()
|
).exec()
|
||||||
const projectIds = projects.map(p => p._id)
|
const projectIds = projects.map(p => p._id)
|
||||||
logger.log({ projectIds, fromUserId, toUserId }, 'transferring projects')
|
logger.debug({ projectIds, fromUserId, toUserId }, 'transferring projects')
|
||||||
|
|
||||||
await Project.updateMany(
|
await Project.updateMany(
|
||||||
{ owner_ref: fromUserId },
|
{ owner_ref: fromUserId },
|
||||||
|
|
|
@ -30,7 +30,7 @@ const rateLimiter = require('../../infrastructure/RateLimiter')
|
||||||
module.exports = CollaboratorsInviteController = {
|
module.exports = CollaboratorsInviteController = {
|
||||||
getAllInvites(req, res, next) {
|
getAllInvites(req, res, next) {
|
||||||
const projectId = req.params.Project_id
|
const projectId = req.params.Project_id
|
||||||
logger.log({ projectId }, 'getting all active invites for project')
|
logger.debug({ projectId }, 'getting all active invites for project')
|
||||||
return CollaboratorsInviteHandler.getAllInvites(
|
return CollaboratorsInviteHandler.getAllInvites(
|
||||||
projectId,
|
projectId,
|
||||||
function (err, invites) {
|
function (err, invites) {
|
||||||
|
@ -50,7 +50,7 @@ module.exports = CollaboratorsInviteController = {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
if (Settings.restrictInvitesToExistingAccounts === true) {
|
if (Settings.restrictInvitesToExistingAccounts === true) {
|
||||||
logger.log({ email }, 'checking if user exists with this email')
|
logger.debug({ email }, 'checking if user exists with this email')
|
||||||
return UserGetter.getUserByAnyEmail(
|
return UserGetter.getUserByAnyEmail(
|
||||||
email,
|
email,
|
||||||
{ _id: 1 },
|
{ _id: 1 },
|
||||||
|
@ -102,13 +102,13 @@ module.exports = CollaboratorsInviteController = {
|
||||||
const sendingUser = SessionManager.getSessionUser(req.session)
|
const sendingUser = SessionManager.getSessionUser(req.session)
|
||||||
const sendingUserId = sendingUser._id
|
const sendingUserId = sendingUser._id
|
||||||
if (email === sendingUser.email) {
|
if (email === sendingUser.email) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ projectId, email, sendingUserId },
|
{ projectId, email, sendingUserId },
|
||||||
'cannot invite yourself to project'
|
'cannot invite yourself to project'
|
||||||
)
|
)
|
||||||
return res.json({ invite: null, error: 'cannot_invite_self' })
|
return res.json({ invite: null, error: 'cannot_invite_self' })
|
||||||
}
|
}
|
||||||
logger.log({ projectId, email, sendingUserId }, 'inviting to project')
|
logger.debug({ projectId, email, sendingUserId }, 'inviting to project')
|
||||||
return LimitationsManager.canAddXCollaborators(
|
return LimitationsManager.canAddXCollaborators(
|
||||||
projectId,
|
projectId,
|
||||||
1,
|
1,
|
||||||
|
@ -118,7 +118,7 @@ module.exports = CollaboratorsInviteController = {
|
||||||
return next(error)
|
return next(error)
|
||||||
}
|
}
|
||||||
if (!allowed) {
|
if (!allowed) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ projectId, email, sendingUserId },
|
{ projectId, email, sendingUserId },
|
||||||
'not allowed to invite more users to project'
|
'not allowed to invite more users to project'
|
||||||
)
|
)
|
||||||
|
@ -127,7 +127,7 @@ module.exports = CollaboratorsInviteController = {
|
||||||
;({ email, privileges } = req.body)
|
;({ email, privileges } = req.body)
|
||||||
email = EmailHelper.parseEmail(email)
|
email = EmailHelper.parseEmail(email)
|
||||||
if (email == null || email === '') {
|
if (email == null || email === '') {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ projectId, email, sendingUserId },
|
{ projectId, email, sendingUserId },
|
||||||
'invalid email address'
|
'invalid email address'
|
||||||
)
|
)
|
||||||
|
@ -158,7 +158,7 @@ module.exports = CollaboratorsInviteController = {
|
||||||
return next(err)
|
return next(err)
|
||||||
}
|
}
|
||||||
if (!shouldAllowInvite) {
|
if (!shouldAllowInvite) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ email, projectId, sendingUserId },
|
{ email, projectId, sendingUserId },
|
||||||
'not allowed to send an invite to this email address'
|
'not allowed to send an invite to this email address'
|
||||||
)
|
)
|
||||||
|
@ -181,7 +181,7 @@ module.exports = CollaboratorsInviteController = {
|
||||||
})
|
})
|
||||||
return next(err)
|
return next(err)
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ projectId, email, sendingUserId },
|
{ projectId, email, sendingUserId },
|
||||||
'invite created'
|
'invite created'
|
||||||
)
|
)
|
||||||
|
@ -204,7 +204,7 @@ module.exports = CollaboratorsInviteController = {
|
||||||
revokeInvite(req, res, next) {
|
revokeInvite(req, res, next) {
|
||||||
const projectId = req.params.Project_id
|
const projectId = req.params.Project_id
|
||||||
const inviteId = req.params.invite_id
|
const inviteId = req.params.invite_id
|
||||||
logger.log({ projectId, inviteId }, 'revoking invite')
|
logger.debug({ projectId, inviteId }, 'revoking invite')
|
||||||
return CollaboratorsInviteHandler.revokeInvite(
|
return CollaboratorsInviteHandler.revokeInvite(
|
||||||
projectId,
|
projectId,
|
||||||
inviteId,
|
inviteId,
|
||||||
|
@ -229,7 +229,7 @@ module.exports = CollaboratorsInviteController = {
|
||||||
resendInvite(req, res, next) {
|
resendInvite(req, res, next) {
|
||||||
const projectId = req.params.Project_id
|
const projectId = req.params.Project_id
|
||||||
const inviteId = req.params.invite_id
|
const inviteId = req.params.invite_id
|
||||||
logger.log({ projectId, inviteId }, 'resending invite')
|
logger.debug({ projectId, inviteId }, 'resending invite')
|
||||||
const sendingUser = SessionManager.getSessionUser(req.session)
|
const sendingUser = SessionManager.getSessionUser(req.session)
|
||||||
return CollaboratorsInviteController._checkRateLimit(
|
return CollaboratorsInviteController._checkRateLimit(
|
||||||
sendingUser._id,
|
sendingUser._id,
|
||||||
|
@ -263,7 +263,7 @@ module.exports = CollaboratorsInviteController = {
|
||||||
const projectId = req.params.Project_id
|
const projectId = req.params.Project_id
|
||||||
const { token } = req.params
|
const { token } = req.params
|
||||||
const _renderInvalidPage = function () {
|
const _renderInvalidPage = function () {
|
||||||
logger.log({ projectId }, 'invite not valid, rendering not-valid page')
|
logger.debug({ projectId }, 'invite not valid, rendering not-valid page')
|
||||||
return res.render('project/invite/not-valid', { title: 'Invalid Invite' })
|
return res.render('project/invite/not-valid', { title: 'Invalid Invite' })
|
||||||
}
|
}
|
||||||
// check if the user is already a member of the project
|
// check if the user is already a member of the project
|
||||||
|
@ -279,7 +279,7 @@ module.exports = CollaboratorsInviteController = {
|
||||||
return next(err)
|
return next(err)
|
||||||
}
|
}
|
||||||
if (isMember) {
|
if (isMember) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ projectId, userId: currentUser._id },
|
{ projectId, userId: currentUser._id },
|
||||||
'user is already a member of this project, redirecting'
|
'user is already a member of this project, redirecting'
|
||||||
)
|
)
|
||||||
|
@ -298,7 +298,7 @@ module.exports = CollaboratorsInviteController = {
|
||||||
}
|
}
|
||||||
// check if invite is gone, or otherwise non-existent
|
// check if invite is gone, or otherwise non-existent
|
||||||
if (invite == null) {
|
if (invite == null) {
|
||||||
logger.log({ projectId }, 'no invite found for this token')
|
logger.debug({ projectId }, 'no invite found for this token')
|
||||||
return _renderInvalidPage()
|
return _renderInvalidPage()
|
||||||
}
|
}
|
||||||
// check the user who sent the invite exists
|
// check the user who sent the invite exists
|
||||||
|
@ -313,7 +313,7 @@ module.exports = CollaboratorsInviteController = {
|
||||||
return next(err)
|
return next(err)
|
||||||
}
|
}
|
||||||
if (owner == null) {
|
if (owner == null) {
|
||||||
logger.log({ projectId }, 'no project owner found')
|
logger.debug({ projectId }, 'no project owner found')
|
||||||
return _renderInvalidPage()
|
return _renderInvalidPage()
|
||||||
}
|
}
|
||||||
// fetch the project name
|
// fetch the project name
|
||||||
|
@ -328,7 +328,7 @@ module.exports = CollaboratorsInviteController = {
|
||||||
return next(err)
|
return next(err)
|
||||||
}
|
}
|
||||||
if (project == null) {
|
if (project == null) {
|
||||||
logger.log({ projectId }, 'no project found')
|
logger.debug({ projectId }, 'no project found')
|
||||||
return _renderInvalidPage()
|
return _renderInvalidPage()
|
||||||
}
|
}
|
||||||
// finally render the invite
|
// finally render the invite
|
||||||
|
@ -352,7 +352,7 @@ module.exports = CollaboratorsInviteController = {
|
||||||
const projectId = req.params.Project_id
|
const projectId = req.params.Project_id
|
||||||
const { token } = req.params
|
const { token } = req.params
|
||||||
const currentUser = SessionManager.getSessionUser(req.session)
|
const currentUser = SessionManager.getSessionUser(req.session)
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ projectId, userId: currentUser._id },
|
{ projectId, userId: currentUser._id },
|
||||||
'got request to accept invite'
|
'got request to accept invite'
|
||||||
)
|
)
|
||||||
|
|
|
@ -28,7 +28,7 @@ const CollaboratorsInviteHandler = {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
logger.log({ projectId }, 'fetching invites for project')
|
logger.debug({ projectId }, 'fetching invites for project')
|
||||||
return ProjectInvite.find({ projectId }, function (err, invites) {
|
return ProjectInvite.find({ projectId }, function (err, invites) {
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
OError.tag(err, 'error getting invites from mongo', {
|
OError.tag(err, 'error getting invites from mongo', {
|
||||||
|
@ -36,7 +36,7 @@ const CollaboratorsInviteHandler = {
|
||||||
})
|
})
|
||||||
return callback(err)
|
return callback(err)
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ projectId, count: invites.length },
|
{ projectId, count: invites.length },
|
||||||
'found invites for project'
|
'found invites for project'
|
||||||
)
|
)
|
||||||
|
@ -48,7 +48,7 @@ const CollaboratorsInviteHandler = {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
logger.log({ projectId }, 'counting invites for project')
|
logger.debug({ projectId }, 'counting invites for project')
|
||||||
return ProjectInvite.countDocuments({ projectId }, function (err, count) {
|
return ProjectInvite.countDocuments({ projectId }, function (err, count) {
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
OError.tag(err, 'error getting invites from mongo', {
|
OError.tag(err, 'error getting invites from mongo', {
|
||||||
|
@ -77,7 +77,10 @@ const CollaboratorsInviteHandler = {
|
||||||
return callback(err)
|
return callback(err)
|
||||||
}
|
}
|
||||||
if (existingUser == null) {
|
if (existingUser == null) {
|
||||||
logger.log({ projectId, email }, 'no existing user found, returning')
|
logger.debug(
|
||||||
|
{ projectId, email },
|
||||||
|
'no existing user found, returning'
|
||||||
|
)
|
||||||
return callback(null)
|
return callback(null)
|
||||||
}
|
}
|
||||||
return ProjectGetter.getProject(
|
return ProjectGetter.getProject(
|
||||||
|
@ -92,7 +95,7 @@ const CollaboratorsInviteHandler = {
|
||||||
return callback(err)
|
return callback(err)
|
||||||
}
|
}
|
||||||
if (project == null) {
|
if (project == null) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ projectId },
|
{ projectId },
|
||||||
'no project found while sending notification, returning'
|
'no project found while sending notification, returning'
|
||||||
)
|
)
|
||||||
|
@ -126,7 +129,7 @@ const CollaboratorsInviteHandler = {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ projectId, inviteId: invite._id },
|
{ projectId, inviteId: invite._id },
|
||||||
'sending notification and email for invite'
|
'sending notification and email for invite'
|
||||||
)
|
)
|
||||||
|
@ -158,7 +161,7 @@ const CollaboratorsInviteHandler = {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ projectId, sendingUserId: sendingUser._id, email, privileges },
|
{ projectId, sendingUserId: sendingUser._id, email, privileges },
|
||||||
'adding invite'
|
'adding invite'
|
||||||
)
|
)
|
||||||
|
@ -211,7 +214,7 @@ const CollaboratorsInviteHandler = {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
logger.log({ projectId, inviteId }, 'removing invite')
|
logger.debug({ projectId, inviteId }, 'removing invite')
|
||||||
return ProjectInvite.deleteOne(
|
return ProjectInvite.deleteOne(
|
||||||
{ projectId, _id: inviteId },
|
{ projectId, _id: inviteId },
|
||||||
function (err) {
|
function (err) {
|
||||||
|
@ -235,7 +238,7 @@ const CollaboratorsInviteHandler = {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
logger.log({ projectId, inviteId }, 'resending invite email')
|
logger.debug({ projectId, inviteId }, 'resending invite email')
|
||||||
return ProjectInvite.findOne(
|
return ProjectInvite.findOne(
|
||||||
{ _id: inviteId, projectId },
|
{ _id: inviteId, projectId },
|
||||||
function (err, invite) {
|
function (err, invite) {
|
||||||
|
@ -276,7 +279,7 @@ const CollaboratorsInviteHandler = {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
logger.log({ projectId }, 'fetching invite by token')
|
logger.debug({ projectId }, 'fetching invite by token')
|
||||||
return ProjectInvite.findOne(
|
return ProjectInvite.findOne(
|
||||||
{ projectId, token: tokenString },
|
{ projectId, token: tokenString },
|
||||||
function (err, invite) {
|
function (err, invite) {
|
||||||
|
@ -299,7 +302,7 @@ const CollaboratorsInviteHandler = {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
logger.log({ projectId, userId: user._id }, 'accepting invite')
|
logger.debug({ projectId, userId: user._id }, 'accepting invite')
|
||||||
return CollaboratorsInviteHandler.getInviteByToken(
|
return CollaboratorsInviteHandler.getInviteByToken(
|
||||||
projectId,
|
projectId,
|
||||||
tokenString,
|
tokenString,
|
||||||
|
@ -313,7 +316,7 @@ const CollaboratorsInviteHandler = {
|
||||||
}
|
}
|
||||||
if (!invite) {
|
if (!invite) {
|
||||||
err = new Errors.NotFoundError('no matching invite found')
|
err = new Errors.NotFoundError('no matching invite found')
|
||||||
logger.log({ err, projectId }, 'no matching invite found')
|
logger.debug({ err, projectId }, 'no matching invite found')
|
||||||
return callback(err)
|
return callback(err)
|
||||||
}
|
}
|
||||||
const inviteId = invite._id
|
const inviteId = invite._id
|
||||||
|
@ -332,7 +335,7 @@ const CollaboratorsInviteHandler = {
|
||||||
return callback(err)
|
return callback(err)
|
||||||
}
|
}
|
||||||
// Remove invite
|
// Remove invite
|
||||||
logger.log({ projectId, inviteId }, 'removing invite')
|
logger.debug({ projectId, inviteId }, 'removing invite')
|
||||||
return ProjectInvite.deleteOne({ _id: inviteId }, function (err) {
|
return ProjectInvite.deleteOne({ _id: inviteId }, function (err) {
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
OError.tag(err, 'error removing invite', {
|
OError.tag(err, 'error removing invite', {
|
||||||
|
|
|
@ -220,7 +220,7 @@ const ClsiManager = {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (validationProblems != null) {
|
if (validationProblems != null) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ projectId, validationProblems },
|
{ projectId, validationProblems },
|
||||||
'problems with users latex before compile was attempted'
|
'problems with users latex before compile was attempted'
|
||||||
)
|
)
|
||||||
|
@ -395,7 +395,7 @@ const ClsiManager = {
|
||||||
const currentCompileTime = results.currentBackend.finishTime
|
const currentCompileTime = results.currentBackend.finishTime
|
||||||
const newBackendCompileTime = results.newBackend.finishTime || 0
|
const newBackendCompileTime = results.newBackend.finishTime || 0
|
||||||
const timeDifference = newBackendCompileTime - currentCompileTime
|
const timeDifference = newBackendCompileTime - currentCompileTime
|
||||||
logger.log(
|
logger.debug(
|
||||||
{
|
{
|
||||||
statusCodeSame,
|
statusCodeSame,
|
||||||
timeDifference,
|
timeDifference,
|
||||||
|
|
|
@ -229,7 +229,7 @@ module.exports = CompileController = {
|
||||||
logger.err({ err }, 'error checking rate limit for pdf download')
|
logger.err({ err }, 'error checking rate limit for pdf download')
|
||||||
return res.sendStatus(500)
|
return res.sendStatus(500)
|
||||||
} else if (!canContinue) {
|
} else if (!canContinue) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, ip: req.ip },
|
{ project_id, ip: req.ip },
|
||||||
'rate limit hit downloading pdf'
|
'rate limit hit downloading pdf'
|
||||||
)
|
)
|
||||||
|
|
|
@ -26,7 +26,7 @@ module.exports = CooldownManager = {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ projectId },
|
{ projectId },
|
||||||
`[Cooldown] putting project on cooldown for ${COOLDOWN_IN_SECONDS} seconds`
|
`[Cooldown] putting project on cooldown for ${COOLDOWN_IN_SECONDS} seconds`
|
||||||
)
|
)
|
||||||
|
|
|
@ -27,7 +27,7 @@ module.exports = CooldownMiddleware = {
|
||||||
return next(err)
|
return next(err)
|
||||||
}
|
}
|
||||||
if (projectIsOnCooldown) {
|
if (projectIsOnCooldown) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ projectId },
|
{ projectId },
|
||||||
'[Cooldown] project is on cooldown, denying request'
|
'[Cooldown] project is on cooldown, denying request'
|
||||||
)
|
)
|
||||||
|
|
|
@ -130,7 +130,7 @@ function getDoc(projectId, docId, options, callback) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
if (res.statusCode >= 200 && res.statusCode < 300) {
|
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ docId, projectId, version: doc.version, rev: doc.rev },
|
{ docId, projectId, version: doc.version, rev: doc.rev },
|
||||||
'got doc from docstore api'
|
'got doc from docstore api'
|
||||||
)
|
)
|
||||||
|
@ -199,7 +199,10 @@ function updateDoc(projectId, docId, lines, version, ranges, callback) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
if (res.statusCode >= 200 && res.statusCode < 300) {
|
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||||
logger.log({ projectId, docId }, 'update doc in docstore url finished')
|
logger.debug(
|
||||||
|
{ projectId, docId },
|
||||||
|
'update doc in docstore url finished'
|
||||||
|
)
|
||||||
callback(null, result.modified, result.rev)
|
callback(null, result.modified, result.rev)
|
||||||
} else {
|
} else {
|
||||||
error = new OError(
|
error = new OError(
|
||||||
|
@ -226,7 +229,7 @@ function destroyProject(projectId, callback) {
|
||||||
|
|
||||||
function _operateOnProject(projectId, method, callback) {
|
function _operateOnProject(projectId, method, callback) {
|
||||||
const url = `${settings.apis.docstore.url}/project/${projectId}/${method}`
|
const url = `${settings.apis.docstore.url}/project/${projectId}/${method}`
|
||||||
logger.log({ projectId }, `calling ${method} for project in docstore`)
|
logger.debug({ projectId }, `calling ${method} for project in docstore`)
|
||||||
// use default timeout for archiving/unarchiving/destroying
|
// use default timeout for archiving/unarchiving/destroying
|
||||||
request.post(url, (err, res, docs) => {
|
request.post(url, (err, res, docs) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
@ -102,7 +102,7 @@ function setDocument(req, res, next) {
|
||||||
})
|
})
|
||||||
return next(error)
|
return next(error)
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ docId, projectId },
|
{ docId, projectId },
|
||||||
'finished receiving set document request from api (docupdater)'
|
'finished receiving set document request from api (docupdater)'
|
||||||
)
|
)
|
||||||
|
|
|
@ -24,13 +24,13 @@ module.exports = ProjectZipStreamManager = {
|
||||||
return cb(error)
|
return cb(error)
|
||||||
}
|
}
|
||||||
if (!project) {
|
if (!project) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ projectId },
|
{ projectId },
|
||||||
'cannot append project to zip stream: project not found'
|
'cannot append project to zip stream: project not found'
|
||||||
)
|
)
|
||||||
return cb()
|
return cb()
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ projectId, name: project.name },
|
{ projectId, name: project.name },
|
||||||
'appending project to zip stream'
|
'appending project to zip stream'
|
||||||
)
|
)
|
||||||
|
@ -42,7 +42,10 @@ module.exports = ProjectZipStreamManager = {
|
||||||
}
|
}
|
||||||
archive.append(stream, { name: `${project.name}.zip` })
|
archive.append(stream, { name: `${project.name}.zip` })
|
||||||
stream.on('end', () => {
|
stream.on('end', () => {
|
||||||
logger.log({ projectId, name: project.name }, 'zip stream ended')
|
logger.debug(
|
||||||
|
{ projectId, name: project.name },
|
||||||
|
'zip stream ended'
|
||||||
|
)
|
||||||
cb()
|
cb()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -51,7 +54,7 @@ module.exports = ProjectZipStreamManager = {
|
||||||
})
|
})
|
||||||
|
|
||||||
async.series(jobs, () => {
|
async.series(jobs, () => {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ projectIds },
|
{ projectIds },
|
||||||
'finished creating zip stream of multiple projects'
|
'finished creating zip stream of multiple projects'
|
||||||
)
|
)
|
||||||
|
@ -97,7 +100,7 @@ module.exports = ProjectZipStreamManager = {
|
||||||
if (path[0] === '/') {
|
if (path[0] === '/') {
|
||||||
path = path.slice(1)
|
path = path.slice(1)
|
||||||
}
|
}
|
||||||
logger.log({ projectId }, 'Adding doc')
|
logger.debug({ projectId }, 'Adding doc')
|
||||||
archive.append(doc.lines.join('\n'), { name: path })
|
archive.append(doc.lines.join('\n'), { name: path })
|
||||||
setImmediate(cb)
|
setImmediate(cb)
|
||||||
})
|
})
|
||||||
|
|
|
@ -356,7 +356,7 @@ const EditorController = {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
logger.log({ project_id, path }, "making directories if they don't exist")
|
logger.debug({ project_id, path }, "making directories if they don't exist")
|
||||||
return ProjectEntityUpdateHandler.mkdirp(
|
return ProjectEntityUpdateHandler.mkdirp(
|
||||||
project_id,
|
project_id,
|
||||||
path,
|
path,
|
||||||
|
@ -402,7 +402,7 @@ const EditorController = {
|
||||||
})
|
})
|
||||||
return callback(err)
|
return callback(err)
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, entity_id, entityType },
|
{ project_id, entity_id, entityType },
|
||||||
'telling users entity has been deleted'
|
'telling users entity has been deleted'
|
||||||
)
|
)
|
||||||
|
@ -441,7 +441,7 @@ const EditorController = {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
logger.log({ project_id, description }, 'updating project description')
|
logger.debug({ project_id, description }, 'updating project description')
|
||||||
return ProjectDetailsHandler.setProjectDescription(
|
return ProjectDetailsHandler.setProjectDescription(
|
||||||
project_id,
|
project_id,
|
||||||
description,
|
description,
|
||||||
|
|
|
@ -25,14 +25,14 @@ function getClient() {
|
||||||
if (EMAIL_SETTINGS.parameters) {
|
if (EMAIL_SETTINGS.parameters) {
|
||||||
const emailParameters = EMAIL_SETTINGS.parameters
|
const emailParameters = EMAIL_SETTINGS.parameters
|
||||||
if (emailParameters.AWSAccessKeyID || EMAIL_SETTINGS.driver === 'ses') {
|
if (emailParameters.AWSAccessKeyID || EMAIL_SETTINGS.driver === 'ses') {
|
||||||
logger.log('using aws ses for email')
|
logger.debug('using aws ses for email')
|
||||||
client = nodemailer.createTransport(sesTransport(emailParameters))
|
client = nodemailer.createTransport(sesTransport(emailParameters))
|
||||||
} else if (emailParameters.sendgridApiKey) {
|
} else if (emailParameters.sendgridApiKey) {
|
||||||
throw new OError(
|
throw new OError(
|
||||||
'sendgridApiKey configuration option is deprecated, use SMTP instead'
|
'sendgridApiKey configuration option is deprecated, use SMTP instead'
|
||||||
)
|
)
|
||||||
} else if (emailParameters.MandrillApiKey) {
|
} else if (emailParameters.MandrillApiKey) {
|
||||||
logger.log('using mandril for email')
|
logger.debug('using mandril for email')
|
||||||
client = nodemailer.createTransport(
|
client = nodemailer.createTransport(
|
||||||
mandrillTransport({
|
mandrillTransport({
|
||||||
auth: {
|
auth: {
|
||||||
|
@ -41,7 +41,7 @@ function getClient() {
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
logger.log('using smtp for email')
|
logger.debug('using smtp for email')
|
||||||
const smtp = _.pick(
|
const smtp = _.pick(
|
||||||
emailParameters,
|
emailParameters,
|
||||||
'host',
|
'host',
|
||||||
|
@ -60,7 +60,7 @@ function getClient() {
|
||||||
)
|
)
|
||||||
client = {
|
client = {
|
||||||
async sendMail(options) {
|
async sendMail(options) {
|
||||||
logger.log({ options }, 'Would send email if enabled.')
|
logger.debug({ options }, 'Would send email if enabled.')
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ async function sendEmail(options) {
|
||||||
try {
|
try {
|
||||||
const canContinue = await checkCanSendEmail(options)
|
const canContinue = await checkCanSendEmail(options)
|
||||||
if (!canContinue) {
|
if (!canContinue) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{
|
{
|
||||||
sendingUser_id: options.sendingUser_id,
|
sendingUser_id: options.sendingUser_id,
|
||||||
to: options.to,
|
to: options.to,
|
||||||
|
|
|
@ -54,7 +54,7 @@ module.exports = {
|
||||||
function (err, export_data) {
|
function (err, export_data) {
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
if (err.forwardResponse != null) {
|
if (err.forwardResponse != null) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ responseError: err.forwardResponse },
|
{ responseError: err.forwardResponse },
|
||||||
'forwarding response'
|
'forwarding response'
|
||||||
)
|
)
|
||||||
|
@ -64,7 +64,7 @@ module.exports = {
|
||||||
return next(err)
|
return next(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{
|
{
|
||||||
user_id,
|
user_id,
|
||||||
project_id,
|
project_id,
|
||||||
|
|
|
@ -30,7 +30,7 @@ const FileStoreHandler = {
|
||||||
return callback(new Error('error getting stat, not available'))
|
return callback(new Error('error getting stat, not available'))
|
||||||
}
|
}
|
||||||
if (!stat.isFile()) {
|
if (!stat.isFile()) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ projectId, fileArgs, fsPath },
|
{ projectId, fileArgs, fsPath },
|
||||||
'tried to upload symlink, not continuing'
|
'tried to upload symlink, not continuing'
|
||||||
)
|
)
|
||||||
|
@ -162,7 +162,7 @@ const FileStoreHandler = {
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteFile(projectId, fileId, callback) {
|
deleteFile(projectId, fileId, callback) {
|
||||||
logger.log({ projectId, fileId }, 'telling file store to delete file')
|
logger.debug({ projectId, fileId }, 'telling file store to delete file')
|
||||||
const opts = {
|
const opts = {
|
||||||
method: 'delete',
|
method: 'delete',
|
||||||
uri: this._buildUrl(projectId, fileId),
|
uri: this._buildUrl(projectId, fileId),
|
||||||
|
@ -202,7 +202,7 @@ const FileStoreHandler = {
|
||||||
},
|
},
|
||||||
|
|
||||||
copyFile(oldProjectId, oldFileId, newProjectId, newFileId, callback) {
|
copyFile(oldProjectId, oldFileId, newProjectId, newFileId, callback) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ oldProjectId, oldFileId, newProjectId, newFileId },
|
{ oldProjectId, oldFileId, newProjectId, newFileId },
|
||||||
'telling filestore to copy a file'
|
'telling filestore to copy a file'
|
||||||
)
|
)
|
||||||
|
|
|
@ -34,7 +34,7 @@ module.exports = InactiveProjectManager = {
|
||||||
})
|
})
|
||||||
return callback(err)
|
return callback(err)
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id, active: project.active },
|
{ project_id, active: project.active },
|
||||||
'seeing if need to reactivate project'
|
'seeing if need to reactivate project'
|
||||||
)
|
)
|
||||||
|
@ -94,7 +94,7 @@ module.exports = InactiveProjectManager = {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ numberOfProjects: projects && projects.length },
|
{ numberOfProjects: projects && projects.length },
|
||||||
'deactivating projects'
|
'deactivating projects'
|
||||||
)
|
)
|
||||||
|
@ -108,7 +108,7 @@ module.exports = InactiveProjectManager = {
|
||||||
},
|
},
|
||||||
|
|
||||||
deactivateProject(project_id, callback) {
|
deactivateProject(project_id, callback) {
|
||||||
logger.log({ project_id }, 'deactivating inactive project')
|
logger.debug({ project_id }, 'deactivating inactive project')
|
||||||
const jobs = [
|
const jobs = [
|
||||||
cb => DocstoreManager.archiveProject(project_id, cb),
|
cb => DocstoreManager.archiveProject(project_id, cb),
|
||||||
cb => ProjectUpdateHandler.markAsInactive(project_id, cb),
|
cb => ProjectUpdateHandler.markAsInactive(project_id, cb),
|
||||||
|
|
|
@ -20,7 +20,7 @@ const logger = require('@overleaf/logger')
|
||||||
module.exports = MetaController = {
|
module.exports = MetaController = {
|
||||||
getMetadata(req, res, next) {
|
getMetadata(req, res, next) {
|
||||||
const { project_id } = req.params
|
const { project_id } = req.params
|
||||||
logger.log({ project_id }, 'getting all labels for project')
|
logger.debug({ project_id }, 'getting all labels for project')
|
||||||
return MetaHandler.getAllMetaForProject(
|
return MetaHandler.getAllMetaForProject(
|
||||||
project_id,
|
project_id,
|
||||||
function (err, projectMeta) {
|
function (err, projectMeta) {
|
||||||
|
@ -43,7 +43,7 @@ module.exports = MetaController = {
|
||||||
const { project_id } = req.params
|
const { project_id } = req.params
|
||||||
const { doc_id } = req.params
|
const { doc_id } = req.params
|
||||||
const { broadcast } = req.body
|
const { broadcast } = req.body
|
||||||
logger.log({ project_id, doc_id, broadcast }, 'getting labels for doc')
|
logger.debug({ project_id, doc_id, broadcast }, 'getting labels for doc')
|
||||||
return MetaHandler.getMetaForDoc(
|
return MetaHandler.getMetaForDoc(
|
||||||
project_id,
|
project_id,
|
||||||
doc_id,
|
doc_id,
|
||||||
|
|
|
@ -23,10 +23,10 @@ class NonFatalEmailUpdateError extends OError {
|
||||||
|
|
||||||
function getProvider() {
|
function getProvider() {
|
||||||
if (mailchimpIsConfigured()) {
|
if (mailchimpIsConfigured()) {
|
||||||
logger.info('Using newsletter provider: mailchimp')
|
logger.debug('Using newsletter provider: mailchimp')
|
||||||
return makeMailchimpProvider()
|
return makeMailchimpProvider()
|
||||||
} else {
|
} else {
|
||||||
logger.info('Using newsletter provider: none')
|
logger.debug('Using newsletter provider: none')
|
||||||
return makeNullProvider()
|
return makeNullProvider()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ function makeMailchimpProvider() {
|
||||||
status_if_new: 'subscribed',
|
status_if_new: 'subscribed',
|
||||||
merge_fields: getMergeFields(user),
|
merge_fields: getMergeFields(user),
|
||||||
})
|
})
|
||||||
logger.info({ user }, 'finished subscribing user to newsletter')
|
logger.debug({ user }, 'finished subscribing user to newsletter')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw OError.tag(err, 'error subscribing user to newsletter', {
|
throw OError.tag(err, 'error subscribing user to newsletter', {
|
||||||
userId: user._id,
|
userId: user._id,
|
||||||
|
@ -89,7 +89,7 @@ function makeMailchimpProvider() {
|
||||||
merge_fields: getMergeFields(user),
|
merge_fields: getMergeFields(user),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
logger.info(
|
logger.debug(
|
||||||
{ user, options },
|
{ user, options },
|
||||||
'finished unsubscribing user from newsletter'
|
'finished unsubscribing user from newsletter'
|
||||||
)
|
)
|
||||||
|
@ -100,7 +100,7 @@ function makeMailchimpProvider() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err.message.includes('looks fake or invalid')) {
|
if (err.message.includes('looks fake or invalid')) {
|
||||||
logger.info(
|
logger.debug(
|
||||||
{ err, user, options },
|
{ err, user, options },
|
||||||
'Mailchimp declined to unsubscribe user because it finds the email looks fake'
|
'Mailchimp declined to unsubscribe user because it finds the email looks fake'
|
||||||
)
|
)
|
||||||
|
@ -121,7 +121,7 @@ function makeMailchimpProvider() {
|
||||||
} catch (updateError) {
|
} catch (updateError) {
|
||||||
// if we failed to update the user, delete their old email address so that
|
// if we failed to update the user, delete their old email address so that
|
||||||
// we don't leave it stuck in mailchimp
|
// we don't leave it stuck in mailchimp
|
||||||
logger.info(
|
logger.debug(
|
||||||
{ oldEmail, newEmail, updateError },
|
{ oldEmail, newEmail, updateError },
|
||||||
'unable to change email in newsletter, removing old mail'
|
'unable to change email in newsletter, removing old mail'
|
||||||
)
|
)
|
||||||
|
@ -161,7 +161,7 @@ function makeMailchimpProvider() {
|
||||||
email_address: newEmail,
|
email_address: newEmail,
|
||||||
merge_fields: getMergeFields(user),
|
merge_fields: getMergeFields(user),
|
||||||
})
|
})
|
||||||
logger.info('finished changing email in the newsletter')
|
logger.debug('finished changing email in the newsletter')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// silently ignore users who were never subscribed
|
// silently ignore users who were never subscribed
|
||||||
if (err.status === 404) {
|
if (err.status === 404) {
|
||||||
|
@ -173,7 +173,7 @@ function makeMailchimpProvider() {
|
||||||
if (err.message.includes(key)) {
|
if (err.message.includes(key)) {
|
||||||
const message = `unable to change email in newsletter, ${errors[key]}`
|
const message = `unable to change email in newsletter, ${errors[key]}`
|
||||||
|
|
||||||
logger.info({ oldEmail, newEmail }, message)
|
logger.debug({ oldEmail, newEmail }, message)
|
||||||
|
|
||||||
throw new NonFatalEmailUpdateError(
|
throw new NonFatalEmailUpdateError(
|
||||||
message,
|
message,
|
||||||
|
@ -218,7 +218,7 @@ function makeNullProvider() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function subscribed(user) {
|
async function subscribed(user) {
|
||||||
logger.info(
|
logger.debug(
|
||||||
{ user },
|
{ user },
|
||||||
'Not checking user because no newsletter provider is configured'
|
'Not checking user because no newsletter provider is configured'
|
||||||
)
|
)
|
||||||
|
@ -226,21 +226,21 @@ function makeNullProvider() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function subscribe(user) {
|
async function subscribe(user) {
|
||||||
logger.info(
|
logger.debug(
|
||||||
{ user },
|
{ user },
|
||||||
'Not subscribing user to newsletter because no newsletter provider is configured'
|
'Not subscribing user to newsletter because no newsletter provider is configured'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function unsubscribe(user) {
|
async function unsubscribe(user) {
|
||||||
logger.info(
|
logger.debug(
|
||||||
{ user },
|
{ user },
|
||||||
'Not unsubscribing user from newsletter because no newsletter provider is configured'
|
'Not unsubscribing user from newsletter because no newsletter provider is configured'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function changeEmail(oldEmail, newEmail) {
|
async function changeEmail(oldEmail, newEmail) {
|
||||||
logger.info(
|
logger.debug(
|
||||||
{ oldEmail, newEmail },
|
{ oldEmail, newEmail },
|
||||||
'Not changing email in newsletter for user because no newsletter provider is configured'
|
'Not changing email in newsletter for user because no newsletter provider is configured'
|
||||||
)
|
)
|
||||||
|
|
|
@ -247,7 +247,7 @@ const ProjectController = {
|
||||||
metrics.inc('cloned-project')
|
metrics.inc('cloned-project')
|
||||||
const projectId = req.params.Project_id
|
const projectId = req.params.Project_id
|
||||||
const { projectName } = req.body
|
const { projectName } = req.body
|
||||||
logger.log({ projectId, projectName }, 'cloning project')
|
logger.debug({ projectId, projectName }, 'cloning project')
|
||||||
if (!SessionManager.isUserLoggedIn(req.session)) {
|
if (!SessionManager.isUserLoggedIn(req.session)) {
|
||||||
return res.json({ redir: '/register' })
|
return res.json({ redir: '/register' })
|
||||||
}
|
}
|
||||||
|
@ -743,7 +743,7 @@ const ProjectController = {
|
||||||
if (err) {
|
if (err) {
|
||||||
return cb(err)
|
return cb(err)
|
||||||
}
|
}
|
||||||
logger.log({ projectId, userId }, 'got user')
|
logger.debug({ projectId, userId }, 'got user')
|
||||||
if (FeaturesUpdater.featuresEpochIsCurrent(user)) {
|
if (FeaturesUpdater.featuresEpochIsCurrent(user)) {
|
||||||
return cb(null, user)
|
return cb(null, user)
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function markAsDeletedByExternalSource(projectId) {
|
async function markAsDeletedByExternalSource(projectId) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ project_id: projectId },
|
{ project_id: projectId },
|
||||||
'marking project as deleted by external data source'
|
'marking project as deleted by external data source'
|
||||||
)
|
)
|
||||||
|
@ -277,7 +277,7 @@ async function deleteProject(projectId, options = {}) {
|
||||||
throw err
|
throw err
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.log({ project_id: projectId }, 'successfully deleted project')
|
logger.debug({ project_id: projectId }, 'successfully deleted project')
|
||||||
}
|
}
|
||||||
|
|
||||||
async function undeleteProject(projectId, options = {}) {
|
async function undeleteProject(projectId, options = {}) {
|
||||||
|
|
|
@ -85,7 +85,7 @@ async function getProjectDescription(projectId) {
|
||||||
async function setProjectDescription(projectId, description) {
|
async function setProjectDescription(projectId, description) {
|
||||||
const conditions = { _id: projectId }
|
const conditions = { _id: projectId }
|
||||||
const update = { description }
|
const update = { description }
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ conditions, update, projectId, description },
|
{ conditions, update, projectId, description },
|
||||||
'setting project description'
|
'setting project description'
|
||||||
)
|
)
|
||||||
|
@ -99,7 +99,7 @@ async function setProjectDescription(projectId, description) {
|
||||||
async function renameProject(projectId, newName) {
|
async function renameProject(projectId, newName) {
|
||||||
newName = newName.trim()
|
newName = newName.trim()
|
||||||
await validateProjectName(newName)
|
await validateProjectName(newName)
|
||||||
logger.log({ projectId, newName }, 'renaming project')
|
logger.debug({ projectId, newName }, 'renaming project')
|
||||||
let project
|
let project
|
||||||
try {
|
try {
|
||||||
project = await ProjectGetter.promises.getProject(projectId, { name: true })
|
project = await ProjectGetter.promises.getProject(projectId, { name: true })
|
||||||
|
|
|
@ -117,7 +117,7 @@ function getDocContext(projectId, docId, callback) {
|
||||||
// 3. web triggers (soft)-delete in docstore
|
// 3. web triggers (soft)-delete in docstore
|
||||||
// Specifically when an update comes in after 1
|
// Specifically when an update comes in after 1
|
||||||
// and before 3 completes.
|
// and before 3 completes.
|
||||||
logger.info(
|
logger.debug(
|
||||||
{ projectId, docId },
|
{ projectId, docId },
|
||||||
'updating doc that is in process of getting soft-deleted'
|
'updating doc that is in process of getting soft-deleted'
|
||||||
)
|
)
|
||||||
|
@ -174,7 +174,10 @@ const ProjectEntityUpdateHandler = {
|
||||||
return callback(err)
|
return callback(err)
|
||||||
}
|
}
|
||||||
const { projectName, isDeletedDoc, path } = ctx
|
const { projectName, isDeletedDoc, path } = ctx
|
||||||
logger.log({ projectId, docId }, 'telling docstore manager to update doc')
|
logger.debug(
|
||||||
|
{ projectId, docId },
|
||||||
|
'telling docstore manager to update doc'
|
||||||
|
)
|
||||||
DocstoreManager.updateDoc(
|
DocstoreManager.updateDoc(
|
||||||
projectId,
|
projectId,
|
||||||
docId,
|
docId,
|
||||||
|
@ -189,7 +192,7 @@ const ProjectEntityUpdateHandler = {
|
||||||
})
|
})
|
||||||
return callback(err)
|
return callback(err)
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ projectId, docId, modified },
|
{ projectId, docId, modified },
|
||||||
'finished updating doc lines'
|
'finished updating doc lines'
|
||||||
)
|
)
|
||||||
|
@ -219,7 +222,7 @@ const ProjectEntityUpdateHandler = {
|
||||||
},
|
},
|
||||||
|
|
||||||
setRootDoc(projectId, newRootDocID, callback) {
|
setRootDoc(projectId, newRootDocID, callback) {
|
||||||
logger.log({ projectId, rootDocId: newRootDocID }, 'setting root doc')
|
logger.debug({ projectId, rootDocId: newRootDocID }, 'setting root doc')
|
||||||
if (projectId == null || newRootDocID == null) {
|
if (projectId == null || newRootDocID == null) {
|
||||||
return callback(
|
return callback(
|
||||||
new Errors.InvalidError('missing arguments (project or doc)')
|
new Errors.InvalidError('missing arguments (project or doc)')
|
||||||
|
@ -251,7 +254,7 @@ const ProjectEntityUpdateHandler = {
|
||||||
},
|
},
|
||||||
|
|
||||||
unsetRootDoc(projectId, callback) {
|
unsetRootDoc(projectId, callback) {
|
||||||
logger.log({ projectId }, 'removing root doc')
|
logger.debug({ projectId }, 'removing root doc')
|
||||||
Project.updateOne(
|
Project.updateOne(
|
||||||
{ _id: projectId },
|
{ _id: projectId },
|
||||||
{ $unset: { rootDoc_id: true } },
|
{ $unset: { rootDoc_id: true } },
|
||||||
|
@ -758,7 +761,7 @@ const ProjectEntityUpdateHandler = {
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
return callback(err)
|
return callback(err)
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ projectId, docId: existingDoc._id },
|
{ projectId, docId: existingDoc._id },
|
||||||
'notifying users that the document has been updated'
|
'notifying users that the document has been updated'
|
||||||
)
|
)
|
||||||
|
@ -1109,7 +1112,7 @@ const ProjectEntityUpdateHandler = {
|
||||||
userId,
|
userId,
|
||||||
callback
|
callback
|
||||||
) {
|
) {
|
||||||
logger.log({ entityId, entityType, projectId }, 'deleting project entity')
|
logger.debug({ entityId, entityType, projectId }, 'deleting project entity')
|
||||||
if (entityType == null) {
|
if (entityType == null) {
|
||||||
logger.warn({ err: 'No entityType set', projectId, entityId })
|
logger.warn({ err: 'No entityType set', projectId, entityId })
|
||||||
return callback(new Error('No entityType set'))
|
return callback(new Error('No entityType set'))
|
||||||
|
@ -1227,7 +1230,7 @@ const ProjectEntityUpdateHandler = {
|
||||||
userId,
|
userId,
|
||||||
callback
|
callback
|
||||||
) {
|
) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ entityType, entityId, projectId, destFolderId },
|
{ entityType, entityId, projectId, destFolderId },
|
||||||
'moving entity'
|
'moving entity'
|
||||||
)
|
)
|
||||||
|
@ -1283,7 +1286,7 @@ const ProjectEntityUpdateHandler = {
|
||||||
if (!SafePath.isCleanFilename(newName)) {
|
if (!SafePath.isCleanFilename(newName)) {
|
||||||
return callback(new Errors.InvalidNameError('invalid element name'))
|
return callback(new Errors.InvalidNameError('invalid element name'))
|
||||||
}
|
}
|
||||||
logger.log({ entityId, projectId }, `renaming ${entityType}`)
|
logger.debug({ entityId, projectId }, `renaming ${entityType}`)
|
||||||
if (entityType == null) {
|
if (entityType == null) {
|
||||||
logger.warn({ err: 'No entityType set', projectId, entityId })
|
logger.warn({ err: 'No entityType set', projectId, entityId })
|
||||||
return callback(new Error('No entityType set'))
|
return callback(new Error('No entityType set'))
|
||||||
|
|
|
@ -29,7 +29,7 @@ const oneMinInMs = 60 * 1000
|
||||||
const fiveMinsInMs = oneMinInMs * 5
|
const fiveMinsInMs = oneMinInMs * 5
|
||||||
|
|
||||||
if (!Features.hasFeature('references')) {
|
if (!Features.hasFeature('references')) {
|
||||||
logger.log('references search not enabled')
|
logger.debug('references search not enabled')
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = ReferencesHandler = {
|
module.exports = ReferencesHandler = {
|
||||||
|
@ -117,7 +117,7 @@ module.exports = ReferencesHandler = {
|
||||||
new Errors.NotFoundError(`project does not exist: ${projectId}`)
|
new Errors.NotFoundError(`project does not exist: ${projectId}`)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
logger.log({ projectId }, 'indexing all bib files in project')
|
logger.debug({ projectId }, 'indexing all bib files in project')
|
||||||
const docIds = ReferencesHandler._findBibDocIds(project)
|
const docIds = ReferencesHandler._findBibDocIds(project)
|
||||||
const fileIds = ReferencesHandler._findBibFileIds(project)
|
const fileIds = ReferencesHandler._findBibFileIds(project)
|
||||||
return ReferencesHandler._doIndexOperation(
|
return ReferencesHandler._doIndexOperation(
|
||||||
|
@ -172,7 +172,7 @@ module.exports = ReferencesHandler = {
|
||||||
})
|
})
|
||||||
return callback(err)
|
return callback(err)
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ projectId, docIds },
|
{ projectId, docIds },
|
||||||
'flushing docs to mongo before calling references service'
|
'flushing docs to mongo before calling references service'
|
||||||
)
|
)
|
||||||
|
@ -213,7 +213,7 @@ module.exports = ReferencesHandler = {
|
||||||
return callback(err)
|
return callback(err)
|
||||||
}
|
}
|
||||||
if (res.statusCode >= 200 && res.statusCode < 300) {
|
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||||
logger.log({ projectId }, 'got keys from references api')
|
logger.debug({ projectId }, 'got keys from references api')
|
||||||
return callback(null, data)
|
return callback(null, data)
|
||||||
} else {
|
} else {
|
||||||
err = new Error(
|
err = new Error(
|
||||||
|
|
|
@ -127,10 +127,10 @@ const AdminController = {
|
||||||
},
|
},
|
||||||
|
|
||||||
writeAllToMongo(req, res) {
|
writeAllToMongo(req, res) {
|
||||||
logger.log('writing all docs to mongo')
|
logger.debug('writing all docs to mongo')
|
||||||
Settings.mongo.writeAll = true
|
Settings.mongo.writeAll = true
|
||||||
return DocumentUpdaterHandler.flushAllDocsToMongo(function () {
|
return DocumentUpdaterHandler.flushAllDocsToMongo(function () {
|
||||||
logger.log('all docs have been saved to mongo')
|
logger.debug('all docs have been saved to mongo')
|
||||||
return res.sendStatus(200)
|
return res.sendStatus(200)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
@ -33,7 +33,7 @@ module.exports = {
|
||||||
if (!languageCodeIsSupported(language)) {
|
if (!languageCodeIsSupported(language)) {
|
||||||
// this log statement can be changed to 'error' once projects with
|
// this log statement can be changed to 'error' once projects with
|
||||||
// unsupported languages are removed from the DB
|
// unsupported languages are removed from the DB
|
||||||
logger.info({ language }, 'language not supported')
|
logger.debug({ language }, 'language not supported')
|
||||||
return res.status(422).json({ misspellings: [] })
|
return res.status(422).json({ misspellings: [] })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ async function refreshFeatures(userId, reason) {
|
||||||
})
|
})
|
||||||
const oldFeatures = _.clone(user.features)
|
const oldFeatures = _.clone(user.features)
|
||||||
const features = await computeFeatures(userId)
|
const features = await computeFeatures(userId)
|
||||||
logger.log({ userId, features }, 'updating user features')
|
logger.debug({ userId, features }, 'updating user features')
|
||||||
|
|
||||||
const matchedFeatureSet = FeaturesHelper.getMatchedFeatureSet(features)
|
const matchedFeatureSet = FeaturesHelper.getMatchedFeatureSet(features)
|
||||||
AnalyticsManager.setUserPropertyForUser(
|
AnalyticsManager.setUserPropertyForUser(
|
||||||
|
@ -51,7 +51,7 @@ async function refreshFeatures(userId, reason) {
|
||||||
const { features: newFeatures, featuresChanged } =
|
const { features: newFeatures, featuresChanged } =
|
||||||
await UserFeaturesUpdater.promises.updateFeatures(userId, features)
|
await UserFeaturesUpdater.promises.updateFeatures(userId, features)
|
||||||
if (oldFeatures.dropbox === true && features.dropbox === false) {
|
if (oldFeatures.dropbox === true && features.dropbox === false) {
|
||||||
logger.log({ userId }, '[FeaturesUpdater] must unlink dropbox')
|
logger.debug({ userId }, '[FeaturesUpdater] must unlink dropbox')
|
||||||
const Modules = require('../../infrastructure/Modules')
|
const Modules = require('../../infrastructure/Modules')
|
||||||
try {
|
try {
|
||||||
await Modules.promises.hooks.fire('removeDropbox', userId, reason)
|
await Modules.promises.hooks.fire('removeDropbox', userId, reason)
|
||||||
|
@ -77,7 +77,7 @@ async function computeFeatures(userId) {
|
||||||
const v1Features = await _getV1Features(user)
|
const v1Features = await _getV1Features(user)
|
||||||
const bonusFeatures = await ReferalFeatures.promises.getBonusFeatures(userId)
|
const bonusFeatures = await ReferalFeatures.promises.getBonusFeatures(userId)
|
||||||
const featuresOverrides = await _getFeaturesOverrides(user)
|
const featuresOverrides = await _getFeaturesOverrides(user)
|
||||||
logger.log(
|
logger.debug(
|
||||||
{
|
{
|
||||||
userId,
|
userId,
|
||||||
individualFeatures,
|
individualFeatures,
|
||||||
|
@ -161,7 +161,7 @@ function _planCodeToFeatures(planCode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function doSyncFromV1(v1UserId) {
|
async function doSyncFromV1(v1UserId) {
|
||||||
logger.log({ v1UserId }, '[AccountSync] starting account sync')
|
logger.debug({ v1UserId }, '[AccountSync] starting account sync')
|
||||||
const user = await UserGetter.promises.getUser(
|
const user = await UserGetter.promises.getUser(
|
||||||
{ 'overleaf.id': v1UserId },
|
{ 'overleaf.id': v1UserId },
|
||||||
{ _id: 1 }
|
{ _id: 1 }
|
||||||
|
@ -170,7 +170,7 @@ async function doSyncFromV1(v1UserId) {
|
||||||
logger.warn({ v1UserId }, '[AccountSync] no user found for v1 id')
|
logger.warn({ v1UserId }, '[AccountSync] no user found for v1 id')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ v1UserId, userId: user._id },
|
{ v1UserId, userId: user._id },
|
||||||
'[AccountSync] updating user subscription and features'
|
'[AccountSync] updating user subscription and features'
|
||||||
)
|
)
|
||||||
|
|
|
@ -36,7 +36,7 @@ async function createAccountForUserId(userId) {
|
||||||
lastName: user.last_name,
|
lastName: user.last_name,
|
||||||
}
|
}
|
||||||
const account = await client.createAccount(accountCreate)
|
const account = await client.createAccount(accountCreate)
|
||||||
logger.log({ userId, account }, 'created recurly account')
|
logger.debug({ userId, account }, 'created recurly account')
|
||||||
return account
|
return account
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ async function getSubscription(subscriptionId) {
|
||||||
|
|
||||||
async function changeSubscription(subscriptionId, body) {
|
async function changeSubscription(subscriptionId, body) {
|
||||||
const change = await client.createSubscriptionChange(subscriptionId, body)
|
const change = await client.createSubscriptionChange(subscriptionId, body)
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ subscriptionId, changeId: change.id },
|
{ subscriptionId, changeId: change.id },
|
||||||
'created subscription change'
|
'created subscription change'
|
||||||
)
|
)
|
||||||
|
@ -59,7 +59,7 @@ async function changeSubscriptionByUuid(subscriptionUuid, ...args) {
|
||||||
|
|
||||||
async function removeSubscriptionChange(subscriptionId) {
|
async function removeSubscriptionChange(subscriptionId) {
|
||||||
const removed = await client.removeSubscriptionChange(subscriptionId)
|
const removed = await client.removeSubscriptionChange(subscriptionId)
|
||||||
logger.log({ subscriptionId }, 'removed pending subscription change')
|
logger.debug({ subscriptionId }, 'removed pending subscription change')
|
||||||
return removed
|
return removed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ async function cancelSubscriptionByUuid(subscriptionUuid) {
|
||||||
if (
|
if (
|
||||||
err.message === 'Only active and future subscriptions can be canceled.'
|
err.message === 'Only active and future subscriptions can be canceled.'
|
||||||
) {
|
) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ subscriptionUuid },
|
{ subscriptionUuid },
|
||||||
'subscription cancellation failed, subscription not active'
|
'subscription cancellation failed, subscription not active'
|
||||||
)
|
)
|
||||||
|
|
|
@ -62,7 +62,7 @@ const RecurlyWrapper = {
|
||||||
checkAccountExists(cache, next) {
|
checkAccountExists(cache, next) {
|
||||||
const { user } = cache
|
const { user } = cache
|
||||||
const { subscriptionDetails } = cache
|
const { subscriptionDetails } = cache
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ user_id: user._id },
|
{ user_id: user._id },
|
||||||
'checking if recurly account exists for user'
|
'checking if recurly account exists for user'
|
||||||
)
|
)
|
||||||
|
@ -85,14 +85,17 @@ const RecurlyWrapper = {
|
||||||
}
|
}
|
||||||
if (response.statusCode === 404) {
|
if (response.statusCode === 404) {
|
||||||
// actually not an error in this case, just no existing account
|
// actually not an error in this case, just no existing account
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ user_id: user._id },
|
{ user_id: user._id },
|
||||||
'user does not currently exist in recurly, proceed'
|
'user does not currently exist in recurly, proceed'
|
||||||
)
|
)
|
||||||
cache.userExists = false
|
cache.userExists = false
|
||||||
return next(null, cache)
|
return next(null, cache)
|
||||||
}
|
}
|
||||||
logger.log({ user_id: user._id }, 'user appears to exist in recurly')
|
logger.debug(
|
||||||
|
{ user_id: user._id },
|
||||||
|
'user appears to exist in recurly'
|
||||||
|
)
|
||||||
return RecurlyWrapper._parseAccountXml(
|
return RecurlyWrapper._parseAccountXml(
|
||||||
responseBody,
|
responseBody,
|
||||||
function (err, account) {
|
function (err, account) {
|
||||||
|
@ -176,7 +179,7 @@ const RecurlyWrapper = {
|
||||||
const { user } = cache
|
const { user } = cache
|
||||||
const { recurlyTokenIds } = cache
|
const { recurlyTokenIds } = cache
|
||||||
const { subscriptionDetails } = cache
|
const { subscriptionDetails } = cache
|
||||||
logger.log({ user_id: user._id }, 'creating billing info in recurly')
|
logger.debug({ user_id: user._id }, 'creating billing info in recurly')
|
||||||
const accountCode = __guard__(
|
const accountCode = __guard__(
|
||||||
cache != null ? cache.account : undefined,
|
cache != null ? cache.account : undefined,
|
||||||
x1 => x1.account_code
|
x1 => x1.account_code
|
||||||
|
@ -231,7 +234,7 @@ const RecurlyWrapper = {
|
||||||
setAddressAndCompanyBillingInfo(cache, next) {
|
setAddressAndCompanyBillingInfo(cache, next) {
|
||||||
const { user } = cache
|
const { user } = cache
|
||||||
const { subscriptionDetails } = cache
|
const { subscriptionDetails } = cache
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ user_id: user._id },
|
{ user_id: user._id },
|
||||||
'setting billing address and company info in recurly'
|
'setting billing address and company info in recurly'
|
||||||
)
|
)
|
||||||
|
@ -303,7 +306,7 @@ const RecurlyWrapper = {
|
||||||
createSubscription(cache, next) {
|
createSubscription(cache, next) {
|
||||||
const { user } = cache
|
const { user } = cache
|
||||||
const { subscriptionDetails } = cache
|
const { subscriptionDetails } = cache
|
||||||
logger.log({ user_id: user._id }, 'creating subscription in recurly')
|
logger.debug({ user_id: user._id }, 'creating subscription in recurly')
|
||||||
const data = {
|
const data = {
|
||||||
plan_code: subscriptionDetails.plan_code,
|
plan_code: subscriptionDetails.plan_code,
|
||||||
currency: subscriptionDetails.currencyCode,
|
currency: subscriptionDetails.currencyCode,
|
||||||
|
@ -367,7 +370,7 @@ const RecurlyWrapper = {
|
||||||
recurlyTokenIds,
|
recurlyTokenIds,
|
||||||
callback
|
callback
|
||||||
) {
|
) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ user_id: user._id },
|
{ user_id: user._id },
|
||||||
'starting process of creating paypal subscription'
|
'starting process of creating paypal subscription'
|
||||||
)
|
)
|
||||||
|
@ -397,7 +400,7 @@ const RecurlyWrapper = {
|
||||||
})
|
})
|
||||||
return callback(err)
|
return callback(err)
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ user_id: user._id },
|
{ user_id: user._id },
|
||||||
'done creating paypal subscription for user'
|
'done creating paypal subscription for user'
|
||||||
)
|
)
|
||||||
|
@ -467,7 +470,7 @@ const RecurlyWrapper = {
|
||||||
|
|
||||||
createSubscription(user, subscriptionDetails, recurlyTokenIds, callback) {
|
createSubscription(user, subscriptionDetails, recurlyTokenIds, callback) {
|
||||||
const { isPaypal } = subscriptionDetails
|
const { isPaypal } = subscriptionDetails
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ user_id: user._id, isPaypal },
|
{ user_id: user._id, isPaypal },
|
||||||
'setting up subscription in recurly'
|
'setting up subscription in recurly'
|
||||||
)
|
)
|
||||||
|
@ -615,7 +618,7 @@ const RecurlyWrapper = {
|
||||||
}
|
}
|
||||||
const items = data[resource]
|
const items = data[resource]
|
||||||
allItems = allItems.concat(items)
|
allItems = allItems.concat(items)
|
||||||
logger.log(
|
logger.debug(
|
||||||
`got another ${items.length}, total now ${allItems.length}`
|
`got another ${items.length}, total now ${allItems.length}`
|
||||||
)
|
)
|
||||||
cursor = __guard__(
|
cursor = __guard__(
|
||||||
|
@ -736,7 +739,7 @@ const RecurlyWrapper = {
|
||||||
},
|
},
|
||||||
|
|
||||||
updateSubscription(subscriptionId, options, callback) {
|
updateSubscription(subscriptionId, options, callback) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ subscriptionId, options },
|
{ subscriptionId, options },
|
||||||
'telling recurly to update subscription'
|
'telling recurly to update subscription'
|
||||||
)
|
)
|
||||||
|
@ -796,7 +799,7 @@ const RecurlyWrapper = {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.log({ coupon_code, requestBody }, 'creating coupon')
|
logger.debug({ coupon_code, requestBody }, 'creating coupon')
|
||||||
return RecurlyWrapper.apiRequest(
|
return RecurlyWrapper.apiRequest(
|
||||||
{
|
{
|
||||||
url: 'coupons',
|
url: 'coupons',
|
||||||
|
@ -840,7 +843,7 @@ const RecurlyWrapper = {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ account_code, coupon_code, requestBody },
|
{ account_code, coupon_code, requestBody },
|
||||||
'redeeming coupon for user'
|
'redeeming coupon for user'
|
||||||
)
|
)
|
||||||
|
@ -868,7 +871,7 @@ const RecurlyWrapper = {
|
||||||
}
|
}
|
||||||
const next_renewal_date = new Date()
|
const next_renewal_date = new Date()
|
||||||
next_renewal_date.setDate(next_renewal_date.getDate() + daysUntilExpire)
|
next_renewal_date.setDate(next_renewal_date.getDate() + daysUntilExpire)
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ subscriptionId, daysUntilExpire },
|
{ subscriptionId, daysUntilExpire },
|
||||||
'Exending Free trial for user'
|
'Exending Free trial for user'
|
||||||
)
|
)
|
||||||
|
|
|
@ -285,7 +285,7 @@ function successfulSubscription(req, res, next) {
|
||||||
|
|
||||||
function cancelSubscription(req, res, next) {
|
function cancelSubscription(req, res, next) {
|
||||||
const user = SessionManager.getSessionUser(req.session)
|
const user = SessionManager.getSessionUser(req.session)
|
||||||
logger.log({ user_id: user._id }, 'canceling subscription')
|
logger.debug({ user_id: user._id }, 'canceling subscription')
|
||||||
SubscriptionHandler.cancelSubscription(user, function (err) {
|
SubscriptionHandler.cancelSubscription(user, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
OError.tag(err, 'something went wrong canceling subscription', {
|
OError.tag(err, 'something went wrong canceling subscription', {
|
||||||
|
@ -307,7 +307,7 @@ function canceledSubscription(req, res, next) {
|
||||||
|
|
||||||
function cancelV1Subscription(req, res, next) {
|
function cancelV1Subscription(req, res, next) {
|
||||||
const userId = SessionManager.getLoggedInUserId(req.session)
|
const userId = SessionManager.getLoggedInUserId(req.session)
|
||||||
logger.log({ userId }, 'canceling v1 subscription')
|
logger.debug({ userId }, 'canceling v1 subscription')
|
||||||
V1SubscriptionManager.cancelV1Subscription(userId, function (err) {
|
V1SubscriptionManager.cancelV1Subscription(userId, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
OError.tag(err, 'something went wrong canceling v1 subscription', {
|
OError.tag(err, 'something went wrong canceling v1 subscription', {
|
||||||
|
@ -331,7 +331,7 @@ function updateSubscription(req, res, next) {
|
||||||
)
|
)
|
||||||
return next(err)
|
return next(err)
|
||||||
}
|
}
|
||||||
logger.log({ planCode, user_id: user._id }, 'updating subscription')
|
logger.debug({ planCode, user_id: user._id }, 'updating subscription')
|
||||||
SubscriptionHandler.updateSubscription(user, planCode, null, function (err) {
|
SubscriptionHandler.updateSubscription(user, planCode, null, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
OError.tag(err, 'something went wrong updating subscription', {
|
OError.tag(err, 'something went wrong updating subscription', {
|
||||||
|
@ -345,7 +345,7 @@ function updateSubscription(req, res, next) {
|
||||||
|
|
||||||
function cancelPendingSubscriptionChange(req, res, next) {
|
function cancelPendingSubscriptionChange(req, res, next) {
|
||||||
const user = SessionManager.getSessionUser(req.session)
|
const user = SessionManager.getSessionUser(req.session)
|
||||||
logger.log({ user_id: user._id }, 'canceling pending subscription change')
|
logger.debug({ user_id: user._id }, 'canceling pending subscription change')
|
||||||
SubscriptionHandler.cancelPendingSubscriptionChange(user, function (err) {
|
SubscriptionHandler.cancelPendingSubscriptionChange(user, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
OError.tag(
|
OError.tag(
|
||||||
|
@ -377,7 +377,7 @@ function updateAccountEmailAddress(req, res, next) {
|
||||||
|
|
||||||
function reactivateSubscription(req, res, next) {
|
function reactivateSubscription(req, res, next) {
|
||||||
const user = SessionManager.getSessionUser(req.session)
|
const user = SessionManager.getSessionUser(req.session)
|
||||||
logger.log({ user_id: user._id }, 'reactivating subscription')
|
logger.debug({ user_id: user._id }, 'reactivating subscription')
|
||||||
SubscriptionHandler.reactivateSubscription(user, function (err) {
|
SubscriptionHandler.reactivateSubscription(user, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
OError.tag(err, 'something went wrong reactivating subscription', {
|
OError.tag(err, 'something went wrong reactivating subscription', {
|
||||||
|
@ -390,7 +390,7 @@ function reactivateSubscription(req, res, next) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function recurlyCallback(req, res, next) {
|
function recurlyCallback(req, res, next) {
|
||||||
logger.log({ data: req.body }, 'received recurly callback')
|
logger.debug({ data: req.body }, 'received recurly callback')
|
||||||
const event = Object.keys(req.body)[0]
|
const event = Object.keys(req.body)[0]
|
||||||
const eventData = req.body[event]
|
const eventData = req.body[event]
|
||||||
|
|
||||||
|
@ -473,7 +473,7 @@ function processUpgradeToAnnualPlan(req, res, next) {
|
||||||
const { planName } = req.body
|
const { planName } = req.body
|
||||||
const couponCode = Settings.coupon_codes.upgradeToAnnualPromo[planName]
|
const couponCode = Settings.coupon_codes.upgradeToAnnualPromo[planName]
|
||||||
const annualPlanName = `${planName}-annual`
|
const annualPlanName = `${planName}-annual`
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ user_id: user._id, planName: annualPlanName },
|
{ user_id: user._id, planName: annualPlanName },
|
||||||
'user is upgrading to annual billing with discount'
|
'user is upgrading to annual billing with discount'
|
||||||
)
|
)
|
||||||
|
|
|
@ -7,7 +7,7 @@ const SessionManager = require('../Authentication/SessionManager')
|
||||||
function removeUserFromGroup(req, res, next) {
|
function removeUserFromGroup(req, res, next) {
|
||||||
const subscription = req.entity
|
const subscription = req.entity
|
||||||
const userToRemoveId = req.params.user_id
|
const userToRemoveId = req.params.user_id
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ subscriptionId: subscription._id, userToRemove_id: userToRemoveId },
|
{ subscriptionId: subscription._id, userToRemove_id: userToRemoveId },
|
||||||
'removing user from group subscription'
|
'removing user from group subscription'
|
||||||
)
|
)
|
||||||
|
|
|
@ -20,7 +20,7 @@ const SubscriptionLocator = {
|
||||||
getUsersSubscription(user_or_id, callback) {
|
getUsersSubscription(user_or_id, callback) {
|
||||||
const user_id = SubscriptionLocator._getUserId(user_or_id)
|
const user_id = SubscriptionLocator._getUserId(user_or_id)
|
||||||
Subscription.findOne({ admin_id: user_id }, function (err, subscription) {
|
Subscription.findOne({ admin_id: user_id }, function (err, subscription) {
|
||||||
logger.log({ user_id }, 'got users subscription')
|
logger.debug({ user_id }, 'got users subscription')
|
||||||
callback(err, subscription)
|
callback(err, subscription)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -30,7 +30,7 @@ const SubscriptionLocator = {
|
||||||
Subscription.findOne(
|
Subscription.findOne(
|
||||||
{ admin_id: user_id, groupPlan: false },
|
{ admin_id: user_id, groupPlan: false },
|
||||||
function (err, subscription) {
|
function (err, subscription) {
|
||||||
logger.log({ user_id }, 'got users individual subscription')
|
logger.debug({ user_id }, 'got users individual subscription')
|
||||||
callback(err, subscription)
|
callback(err, subscription)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -233,7 +233,7 @@ const removeLegacyInvite = (subscriptionId, email, callback) =>
|
||||||
|
|
||||||
function checkIfInviteIsPossible(subscription, email, callback) {
|
function checkIfInviteIsPossible(subscription, email, callback) {
|
||||||
if (!subscription.groupPlan) {
|
if (!subscription.groupPlan) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ subscriptionId: subscription.id },
|
{ subscriptionId: subscription.id },
|
||||||
'can not add members to a subscription that is not in a group plan'
|
'can not add members to a subscription that is not in a group plan'
|
||||||
)
|
)
|
||||||
|
@ -241,7 +241,7 @@ function checkIfInviteIsPossible(subscription, email, callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LimitationsManager.teamHasReachedMemberLimit(subscription)) {
|
if (LimitationsManager.teamHasReachedMemberLimit(subscription)) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ subscriptionId: subscription.id },
|
{ subscriptionId: subscription.id },
|
||||||
'team has reached member limit'
|
'team has reached member limit'
|
||||||
)
|
)
|
||||||
|
@ -261,7 +261,7 @@ function checkIfInviteIsPossible(subscription, email, callback) {
|
||||||
)
|
)
|
||||||
|
|
||||||
if (existingMember) {
|
if (existingMember) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ subscriptionId: subscription.id, email },
|
{ subscriptionId: subscription.id, email },
|
||||||
'user already in team'
|
'user already in team'
|
||||||
)
|
)
|
||||||
|
|
|
@ -212,7 +212,7 @@ module.exports = UpdateMerger = {
|
||||||
)
|
)
|
||||||
return callback(err)
|
return callback(err)
|
||||||
}
|
}
|
||||||
logger.log({ docLines }, 'processing doc update from tpds')
|
logger.debug({ docLines }, 'processing doc update from tpds')
|
||||||
return EditorController.upsertDocWithPath(
|
return EditorController.upsertDocWithPath(
|
||||||
project_id,
|
project_id,
|
||||||
path,
|
path,
|
||||||
|
|
|
@ -147,7 +147,7 @@ async function checkAndGetProjectOrResponseAction(
|
||||||
if (isAnonymousUser && tokenAccessEnabled) {
|
if (isAnonymousUser && tokenAccessEnabled) {
|
||||||
if (tokenType === TokenAccessHandler.TOKEN_TYPES.READ_AND_WRITE) {
|
if (tokenType === TokenAccessHandler.TOKEN_TYPES.READ_AND_WRITE) {
|
||||||
if (TokenAccessHandler.ANONYMOUS_READ_AND_WRITE_ENABLED) {
|
if (TokenAccessHandler.ANONYMOUS_READ_AND_WRITE_ENABLED) {
|
||||||
logger.info({ projectId }, 'granting read-write anonymous access')
|
logger.debug({ projectId }, 'granting read-write anonymous access')
|
||||||
TokenAccessHandler.grantSessionTokenAccess(req, projectId, token)
|
TokenAccessHandler.grantSessionTokenAccess(req, projectId, token)
|
||||||
return [
|
return [
|
||||||
null,
|
null,
|
||||||
|
@ -178,7 +178,7 @@ async function checkAndGetProjectOrResponseAction(
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
} else if (tokenType === TokenAccessHandler.TOKEN_TYPES.READ_ONLY) {
|
} else if (tokenType === TokenAccessHandler.TOKEN_TYPES.READ_ONLY) {
|
||||||
logger.info({ projectId }, 'granting read-only anonymous access')
|
logger.debug({ projectId }, 'granting read-only anonymous access')
|
||||||
TokenAccessHandler.grantSessionTokenAccess(req, projectId, token)
|
TokenAccessHandler.grantSessionTokenAccess(req, projectId, token)
|
||||||
return [
|
return [
|
||||||
null,
|
null,
|
||||||
|
|
|
@ -219,7 +219,7 @@ const ArchiveManager = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const timer = new metrics.Timer('unzipDirectory')
|
const timer = new metrics.Timer('unzipDirectory')
|
||||||
logger.log({ source, destination }, 'unzipping file')
|
logger.debug({ source, destination }, 'unzipping file')
|
||||||
|
|
||||||
return ArchiveManager._extractZipFiles(
|
return ArchiveManager._extractZipFiles(
|
||||||
source,
|
source,
|
||||||
|
|
|
@ -86,7 +86,7 @@ async function addFolderContents(
|
||||||
replace
|
replace
|
||||||
) {
|
) {
|
||||||
if (!(await _isSafeOnFileSystem(folderPath))) {
|
if (!(await _isSafeOnFileSystem(folderPath))) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ userId, projectId, parentFolderId, folderPath },
|
{ userId, projectId, parentFolderId, folderPath },
|
||||||
'add folder contents is from symlink, stopping insert'
|
'add folder contents is from symlink, stopping insert'
|
||||||
)
|
)
|
||||||
|
@ -110,7 +110,7 @@ async function addFolderContents(
|
||||||
|
|
||||||
async function addEntity(userId, projectId, folderId, name, fsPath, replace) {
|
async function addEntity(userId, projectId, folderId, name, fsPath, replace) {
|
||||||
if (!(await _isSafeOnFileSystem(fsPath))) {
|
if (!(await _isSafeOnFileSystem(fsPath))) {
|
||||||
logger.log(
|
logger.debug(
|
||||||
{ userId, projectId, folderId, fsPath },
|
{ userId, projectId, folderId, fsPath },
|
||||||
'add entry is from symlink, stopping insert'
|
'add entry is from symlink, stopping insert'
|
||||||
)
|
)
|
||||||
|
|
|
@ -428,7 +428,7 @@ const UserController = {
|
||||||
doLogout(req, cb) {
|
doLogout(req, cb) {
|
||||||
metrics.inc('user.logout')
|
metrics.inc('user.logout')
|
||||||
const user = SessionManager.getSessionUser(req.session)
|
const user = SessionManager.getSessionUser(req.session)
|
||||||
logger.log({ user }, 'logging out')
|
logger.debug({ user }, 'logging out')
|
||||||
const sessionId = req.sessionID
|
const sessionId = req.sessionID
|
||||||
if (typeof req.logout === 'function') {
|
if (typeof req.logout === 'function') {
|
||||||
req.logout()
|
req.logout()
|
||||||
|
|
|
@ -37,7 +37,7 @@ async function deleteUser(userId, options = {}) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const user = await User.findById(userId).exec()
|
const user = await User.findById(userId).exec()
|
||||||
logger.log({ user }, 'deleting user')
|
logger.debug({ user }, 'deleting user')
|
||||||
|
|
||||||
await ensureCanDeleteUser(user)
|
await ensureCanDeleteUser(user)
|
||||||
await _cleanupUser(user)
|
await _cleanupUser(user)
|
||||||
|
|
|
@ -197,7 +197,7 @@ const UserPagesController = {
|
||||||
|
|
||||||
sessionsPage(req, res, next) {
|
sessionsPage(req, res, next) {
|
||||||
const user = SessionManager.getSessionUser(req.session)
|
const user = SessionManager.getSessionUser(req.session)
|
||||||
logger.log({ userId: user._id }, 'loading sessions page')
|
logger.debug({ userId: user._id }, 'loading sessions page')
|
||||||
const currentSession = {
|
const currentSession = {
|
||||||
ip_address: user.ip_address,
|
ip_address: user.ip_address,
|
||||||
session_created: user.session_created,
|
session_created: user.session_created,
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue