diff --git a/services/document-updater/config/settings.defaults.coffee b/services/document-updater/config/settings.defaults.coffee index 15456db932..3f7abf90c7 100755 --- a/services/document-updater/config/settings.defaults.coffee +++ b/services/document-updater/config/settings.defaults.coffee @@ -32,18 +32,18 @@ module.exports = docVersion: ({doc_id}) -> "DocVersion:#{doc_id}" projectKey: ({doc_id}) -> "ProjectId:#{doc_id}" docsInProject: ({project_id}) -> "DocsIn:#{project_id}" - # }, { - # cluster: [{ - # port: "7000" - # host: "localhost" - # }] - # key_schema: - # blockingKey: ({doc_id}) -> "Blocking:{#{doc_id}}" - # docLines: ({doc_id}) -> "doclines:{#{doc_id}}" - # docOps: ({doc_id}) -> "DocOps:{#{doc_id}}" - # docVersion: ({doc_id}) -> "DocVersion:{#{doc_id}}" - # projectKey: ({doc_id}) -> "ProjectId:{#{doc_id}}" - # docsInProject: ({project_id}) -> "DocsIn:{#{project_id}}" + }, { + cluster: [{ + port: "7000" + host: "localhost" + }] + key_schema: + blockingKey: ({doc_id}) -> "Blocking:{#{doc_id}}" + docLines: ({doc_id}) -> "doclines:{#{doc_id}}" + docOps: ({doc_id}) -> "DocOps:{#{doc_id}}" + docVersion: ({doc_id}) -> "DocVersion:{#{doc_id}}" + projectKey: ({doc_id}) -> "ProjectId:{#{doc_id}}" + docsInProject: ({project_id}) -> "DocsIn:{#{project_id}}" }] max_doc_length: 2 * 1024 * 1024 # 2mb diff --git a/services/document-updater/migrate.coffee b/services/document-updater/migrate.coffee index 13f20e50c2..d0ede23a22 100644 --- a/services/document-updater/migrate.coffee +++ b/services/document-updater/migrate.coffee @@ -2,6 +2,8 @@ RedisManager = require "./app/coffee/RedisManager" UpdateManager = require "./app/coffee/UpdateManager" LockManager = require "./app/coffee/LockManager" +async = require "async" + handleErrorInsideLock = (doc_id, lockValue, original_error, callback = (error) ->) -> LockManager.releaseLock doc_id, lockValue, (lock_error) -> callback(original_error) @@ -17,13 +19,18 @@ migrateDoc = (doc_id, callback = (error) ->) -> return callback(error) if error? UpdateManager.continueProcessingUpdatesWithLock project_id, doc_id, callback -doc_id = process.argv[2] -if !doc_id? - console.log "Usage: coffee migrate.coffee DOC_ID" +doc_ids = process.argv.slice(2) +if doc_ids.length == 0 + console.log "Usage: coffee migrate.coffee DOC_ID [DOC_ID ...]" 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? - setTimeout () -> - process.exit(0) - , 200 \ No newline at end of file + process.exit(0)