mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Allow migrate script to process multi docs at once
This commit is contained in:
parent
6bc78ccf77
commit
9bd7c0017d
2 changed files with 26 additions and 19 deletions
|
@ -32,18 +32,18 @@ module.exports =
|
||||||
docVersion: ({doc_id}) -> "DocVersion:#{doc_id}"
|
docVersion: ({doc_id}) -> "DocVersion:#{doc_id}"
|
||||||
projectKey: ({doc_id}) -> "ProjectId:#{doc_id}"
|
projectKey: ({doc_id}) -> "ProjectId:#{doc_id}"
|
||||||
docsInProject: ({project_id}) -> "DocsIn:#{project_id}"
|
docsInProject: ({project_id}) -> "DocsIn:#{project_id}"
|
||||||
# }, {
|
}, {
|
||||||
# cluster: [{
|
cluster: [{
|
||||||
# port: "7000"
|
port: "7000"
|
||||||
# host: "localhost"
|
host: "localhost"
|
||||||
# }]
|
}]
|
||||||
# key_schema:
|
key_schema:
|
||||||
# blockingKey: ({doc_id}) -> "Blocking:{#{doc_id}}"
|
blockingKey: ({doc_id}) -> "Blocking:{#{doc_id}}"
|
||||||
# docLines: ({doc_id}) -> "doclines:{#{doc_id}}"
|
docLines: ({doc_id}) -> "doclines:{#{doc_id}}"
|
||||||
# docOps: ({doc_id}) -> "DocOps:{#{doc_id}}"
|
docOps: ({doc_id}) -> "DocOps:{#{doc_id}}"
|
||||||
# docVersion: ({doc_id}) -> "DocVersion:{#{doc_id}}"
|
docVersion: ({doc_id}) -> "DocVersion:{#{doc_id}}"
|
||||||
# projectKey: ({doc_id}) -> "ProjectId:{#{doc_id}}"
|
projectKey: ({doc_id}) -> "ProjectId:{#{doc_id}}"
|
||||||
# docsInProject: ({project_id}) -> "DocsIn:{#{project_id}}"
|
docsInProject: ({project_id}) -> "DocsIn:{#{project_id}}"
|
||||||
}]
|
}]
|
||||||
|
|
||||||
max_doc_length: 2 * 1024 * 1024 # 2mb
|
max_doc_length: 2 * 1024 * 1024 # 2mb
|
||||||
|
|
|
@ -2,6 +2,8 @@ RedisManager = require "./app/coffee/RedisManager"
|
||||||
UpdateManager = require "./app/coffee/UpdateManager"
|
UpdateManager = require "./app/coffee/UpdateManager"
|
||||||
LockManager = require "./app/coffee/LockManager"
|
LockManager = require "./app/coffee/LockManager"
|
||||||
|
|
||||||
|
async = require "async"
|
||||||
|
|
||||||
handleErrorInsideLock = (doc_id, lockValue, original_error, callback = (error) ->) ->
|
handleErrorInsideLock = (doc_id, lockValue, original_error, callback = (error) ->) ->
|
||||||
LockManager.releaseLock doc_id, lockValue, (lock_error) ->
|
LockManager.releaseLock doc_id, lockValue, (lock_error) ->
|
||||||
callback(original_error)
|
callback(original_error)
|
||||||
|
@ -17,13 +19,18 @@ migrateDoc = (doc_id, callback = (error) ->) ->
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
UpdateManager.continueProcessingUpdatesWithLock project_id, doc_id, callback
|
UpdateManager.continueProcessingUpdatesWithLock project_id, doc_id, callback
|
||||||
|
|
||||||
doc_id = process.argv[2]
|
doc_ids = process.argv.slice(2)
|
||||||
if !doc_id?
|
if doc_ids.length == 0
|
||||||
console.log "Usage: coffee migrate.coffee DOC_ID"
|
console.log "Usage: coffee migrate.coffee DOC_ID [DOC_ID ...]"
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
|
|
||||||
migrateDoc doc_id, (error) ->
|
jobs = []
|
||||||
|
for doc_id in doc_ids
|
||||||
|
do (doc_id) ->
|
||||||
|
jobs.push (cb) ->
|
||||||
|
console.log "MIGRATING #{doc_id}"
|
||||||
|
migrateDoc doc_id, cb
|
||||||
|
|
||||||
|
async.series jobs, (error) ->
|
||||||
throw error if error?
|
throw error if error?
|
||||||
setTimeout () ->
|
process.exit(0)
|
||||||
process.exit(0)
|
|
||||||
, 200
|
|
||||||
|
|
Loading…
Reference in a new issue