mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
3d9dfeccc3
remove the op-specific code remove tests for ops, now only packing remove unused packing code work in progress store index for completed packs only support archiving and unarchiving of individual packs remove support for archiving whole document history split out ArchiveManager, IndexManager remove old DocArchive code remove docHistoryStats collection comment about archiving added method to look at index when last pack has been archived added start of iterator for project results use a proper iterator added heap module getting it working increase pack size since bulk operations no longer needed remove unused MongoAWSexternal cleanup added doc iterator remove old query code added missing files cleanup clean upclean up started adding pack worker for archiving work in progress work in progress getting pack worker working updating worker getting packworker working added lock use correct key name for track changes aws access use correct key name for track changes aws access always send back users array fix up comparison of retrieved objects handle op ids inside packs log when s3 download completes comments cleanup, remove finalisation ideacleanup, remove finalisation idea remove logging
86 lines
2.6 KiB
CoffeeScript
86 lines
2.6 KiB
CoffeeScript
Settings = require "settings-sharelatex"
|
|
logger = require "logger-sharelatex"
|
|
TrackChangesLogger = logger.initialize("track-changes").logger
|
|
|
|
if Settings.sentry?.dsn?
|
|
logger.initializeErrorReporting(Settings.sentry.dsn)
|
|
|
|
# log updates as truncated strings
|
|
truncateFn = (updates) ->
|
|
JSON.parse(
|
|
JSON.stringify updates, (key, value) ->
|
|
if typeof value == 'string' && (len = value.length) > 80
|
|
return value.substr(0,32) + "...(message of length #{len} truncated)..." + value.substr(-32)
|
|
else
|
|
return value
|
|
)
|
|
|
|
TrackChangesLogger.addSerializers {
|
|
rawUpdate: truncateFn
|
|
rawUpdates: truncateFn
|
|
newUpdates: truncateFn
|
|
lastUpdate: truncateFn
|
|
}
|
|
|
|
Path = require "path"
|
|
Metrics = require "metrics-sharelatex"
|
|
Metrics.initialize("track-changes")
|
|
Metrics.mongodb.monitor(Path.resolve(__dirname + "/node_modules/mongojs/node_modules/mongodb"), logger)
|
|
Metrics.memory.monitor(logger)
|
|
|
|
child_process = require "child_process"
|
|
|
|
HttpController = require "./app/js/HttpController"
|
|
express = require "express"
|
|
app = express()
|
|
|
|
app.use Metrics.http.monitor(logger)
|
|
|
|
app.post "/project/:project_id/doc/:doc_id/flush", HttpController.flushDoc
|
|
|
|
app.get "/project/:project_id/doc/:doc_id/diff", HttpController.getDiff
|
|
|
|
app.get "/project/:project_id/doc/:doc_id/check", HttpController.checkDoc
|
|
|
|
app.get "/project/:project_id/updates", HttpController.getUpdates
|
|
|
|
app.post "/project/:project_id/flush", HttpController.flushProject
|
|
|
|
app.post "/project/:project_id/doc/:doc_id/version/:version/restore", HttpController.restore
|
|
|
|
packWorker = null # use a single packing worker
|
|
|
|
app.post "/pack", (req, res, next) ->
|
|
if packWorker?
|
|
res.send "pack already running"
|
|
else
|
|
logger.log "running pack"
|
|
packWorker = child_process.fork(__dirname + '/app/js/PackWorker.js',
|
|
[req.query.limit, req.query.delay, req.query.timeout])
|
|
packWorker.on 'exit', (code, signal) ->
|
|
logger.log {code, signal}, "history auto pack exited"
|
|
packWorker = null
|
|
res.send "pack started"
|
|
|
|
app.get "/status", (req, res, next) ->
|
|
res.send "track-changes is alive"
|
|
|
|
app.get "/oops", (req, res, next) ->
|
|
throw new Error("dummy test error")
|
|
|
|
app.get "/check_lock", HttpController.checkLock
|
|
|
|
app.get "/health_check", HttpController.healthCheck
|
|
|
|
app.use (error, req, res, next) ->
|
|
logger.error err: error, req: req, "an internal error occured"
|
|
res.send 500
|
|
|
|
port = Settings.internal?.trackchanges?.port or 3015
|
|
host = Settings.internal?.trackchanges?.host or "localhost"
|
|
app.listen port, host, (error) ->
|
|
if error?
|
|
logger.error err: error, "could not start track-changes server"
|
|
else
|
|
logger.info "trackchanges starting up, listening on #{host}:#{port}"
|
|
|